Other Microsoft technologies like Windows Forms have standard CLR events. These are described as:
Only the source element itself is given the opportunity to invoke handlers in response. This is analogous to the "routing" that Windows Forms uses for events.
For WPF, Microsoft have introduced RoutedEvent
s, with three separate Routing Strategies As always, Microsoft has the best explanations of these different strategies (from the linked page):
• Bubbling: Event handlers on the event source are invoked. The routed event then routes to successive parent elements until reaching the element tree root. Most routed events use the bubbling routing strategy. Bubbling routed events are generally used to report input or state changes from distinct controls or other UI elements.
• Direct: Only the source element itself is given the opportunity to invoke handlers in response. This is analogous to the "routing" that Windows Forms uses for events. However, unlike a standard CLR event, direct routed events support class handling (class handling is explained in an upcoming section) and can be used by EventSetter and EventTrigger.
• Tunneling: Initially, event handlers at the element tree root are invoked. The routed event then travels a route through successive child elements along the route, towards the node element that is the routed event source (the element that raised the routed event). Tunneling routed events are often used or handled as part of the compositing for a control, such that events from composite parts can be deliberately suppressed or replaced by events that are specific to the complete control. Input events provided in WPF often come implemented as a tunneling/bubbling pair. Tunneling events are also sometimes referred to as Preview events, because of a naming convention that is used for the pairs.
In simplest terms though, the Tunneling
events, always with names starting with Preview
, occur before Bubbling
events and so are preferable to handle. The actual derived EventArgs
object that a RoutedEvent
uses is shared between both the Tunneling
and the relating Bubbling
events. If an event has a related Tunneling
event, you can be certain that an attached handler will be called, whereas some controls set the Tunneling
event as Handled
, so the relating Bubbling
event is never called.
Please see the linked page for the full details about Routed Events.