Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are routed events weak in WPF

Does routed events in WPF store strong reference to the handler that is attached to them?

like image 548
ligaz Avatar asked Dec 22 '08 16:12

ligaz


People also ask

What is routed event in WPF?

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.

What is bubbling and tunneling in WPF?

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.

Which of the following is a routing strategy of routed events?

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.


1 Answers

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

like image 167
Colby Africa Avatar answered Oct 19 '22 14:10

Colby Africa