Thursday, July 23, 2015

RoutedEvent

RoutedEvent

A Routed Event is similar to .NET events.
However, unlike .NET events (called CLR events in WPF), if an event is not handled by an element receiving the routed event, the routed event will propagate to the children or to the ancestors (depending on the Routing Strategy of the Routed Event) of the element.
The routed event will "route" as long as it is not marked as handled. If an element marks a routed event as handled, the routed event will not propagate to the next element.
There are three routing strategies availlable.
- Bubbling
- Tunneling
- Direct
A Bubbling event is one which propagates from an element towards its ancestor. The starting point of the event is the Original Source of the event, while the ending point is the highest possible ancestor. This is often considered as the informal "default" routing strategy.

A Tunneling event is one which propagates from an element towards its children. The starting point of the event is the highest ancestor of the Original Source of the event, while the ending point is the Original Source itself (the "route" of the event is the exact opposite of that of a Bubbling event).

A Direct event is one which will not route in any direction, it will be sent only to the Original Source. This is the equivalent of a CLR event.

No comments:

Post a Comment