What is a routed event?

What is a routed event?

This is the answer that is typical on Stack Overflow sites and other such forums:

A routed event is a type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.

It seems – with all due respect to those coders – are not applying the old programming adage:

Always write explanations as if the guy who ends up reading it is a violent psychopath who knows where you live.

Now such MSDN techno-speak just hurts everyones’ heads. Why can’t they just speak plain English? I’m no expert, but here it is explained simply so that you can understand:

Explanation By Analogy: What is a routed event?

Our judicial system employs routed events. Suppose that somebody commits a crime. This is an “event”. This event can be handled in any one of the following courts, (from the lowest court to the highest court in the land, respectively):

  1. Lower/Magistrate court
  2. County/Distruct Courts
  3. Supreme Court
  4. State/Territory Court
  5. The High Court
  6. The Privy Council
  7. and above that: The Supreme Court of the Galactic Republic

Now, as is the case, all courts have jurisdiction over the matter. A petty theft can be tried in the High Court – if you wanted to. The High court has jurisdiction, but is that what you really want? Most cases start off in the Lower courts, and then, if required, the matter is passed onto a higher court. And if so required, that court passes on the matter to a still higher court. It can go all the way to the top.

Or on the other hand, if you so decide: the theft can be handled at the lower court, and the matter can end there.

Routed events work the same way. If an event happens in the lower court, you, the programmer, can so choose to have the event “bubble up” and be handled by a higher court. The matter can go as high up as you wish and can be taken care of there.

Now that, in effect, is how routed events work. Something which starts in the Lower Court can be passed on and can be “handled” and heard in the Privy Council. And that’s it! So simple? Yet everyone tries to make it so complicated!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *