Prev | Current Page 323 | Next

Matthew MacDonald

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


If you??™re simply interested in performing first-time initializing for your controls, the best
time to take care of this task is when the Loaded event fires. Usually, you can perform all your
initialization in one place, which is typically an event handler for the Window.Loaded event.
nTip You can also use the window constructor to perform your initialization (just add your code immediately
after the InitializeComponent() call). However, it??™s always better to use the Loaded event. That??™s because
if an exception occurs in the constructor of the Window, it??™s thrown while the XAML parser is parsing the
page. As a result, your exception is wrapped in an unhelpful XamlParseException object (with the original
exception in the InnerException property).
CHAPTER 6 n DEPENDENCY PROPERTIES AND ROUTED EVENTS 168
Input Events
All input events??”events that occur due to mouse, keyboard, or stylus actions??”pass along
extra information in a custom event argument class. In fact, all these classes share a common
ancestor: the InputEventArgs class. Figure 6-5 shows the inheritance hierarchy.
Figure 6-5. The EventArgs classes for input events
The InputEventArgs class adds just two properties: Timestamp and Device. The
Timestamp provides an integer that indicates when the event occurred as a number of milliseconds.


Pages:
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335