Prev | Current Page 309 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

When a control sets
the Handled property to True, the event doesn??™t travel any further and isn??™t
raised for any other elements. (As you??™ll see in the section ???Handling a Suppressed
Event,??? there is one way around this limitation.)
Bubbling Events
Figure 6-1 shows a simple window that demonstrates event bubbling. When you click a part
of the label, the event sequence is shown in a list box. Figure 6-1 shows the appearance of this
window immediately after you click the image in the label. The MouseUp event travels
through five levels, ending up at the custom BubbledLabelClick form.
To create this test form, the image and every element above it in the element hierarchy
are wired up to the same event handler??”a method named SomethingClicked(). Here??™s the
XAML that does it:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BubbledLabelClick" Height="359" Width="329"
MouseUp="SomethingClicked">







CHAPTER 6 n DEPENDENCY PROPERTIES AND ROUTED EVENTS 158