Does routed events in WPF store strong reference to the handler that is attached to them?
A routed event is an event registered with the WPF event system, backed by an instance of the RoutedEvent class, and processed by the WPF event system. The RoutedEvent instance, obtained from registration, is typically stored as a public static readonly member of the class that registered it.
The difference between a bubbling and a tunneling event is that a tunneling event will always start with a preview. In a WPF application, events are often implemented as a tunneling/bubbling pair. So, you'll have a preview MouseDown and then a MouseDown event.
Routed events use one of three routing strategies: Bubbling: Initially, event handlers on the event source are invoked. The routed event then routes to successive parent elements, invoking their event handlers in turn, until it reaches the element tree root. Most routed events use the bubbling routing strategy.
If the control author implemented the WeakEvent pattern then yes. I believe the stock controls use this pattern.
UPDATE: They in fact do NOT. Here is a reference on this and other potential performance problems:
Optimizing WPF Application Performance
Here is a reference on weak events:
Weak Event Patterns
HTH
Colby Africa
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With