Prev | Current Page 307 | Next

Matthew MacDonald

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

The window is the top level of the containment hierarchy and the final stop
in the event bubbling sequence. It??™s your last chance to handle a bubbling event such as
MouseDown. If the user releases the mouse button, the MouseUp event fires in the same
sequence.
nNote In Chapter 9, you??™ll learn how to create a page-based WPF application. In this situation, the
top-level container isn??™t a window, but an instance of the Page class.
You aren??™t limited to handling a bubbling event in one place. In fact, there??™s no reason why
you can??™t handle the MouseDown or MouseUp event at every level. But usually you??™ll choose
the most appropriate level for the task at hand.
The RoutedEventArgs Class
When you handle a bubbling event, the sender parameter provides a reference to the last link
in the chain. For example, if an event bubbles up from an image to a label before you handle
it, the sender parameter references the label object.
In some cases, you??™ll want to determine where the event originally took place. You can get
that information and other details from the properties of the RoutedEventArgs class (which
are listed in Table 6-2). Because all WPF event argument classes inherit from RoutedEventArgs,
these properties are available in any event handler.
CHAPTER 6 n DEPENDENCY PROPERTIES AND ROUTED EVENTS 157
Table 6-2.


Pages:
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319