Handling Events in WPF

You handle events in WPF the same way you do in other kinds of applications: You code a Visual Basic event handler and associate the handler to a control event. What actually changes is the way you assign the handler to the event. For example you can assign an event handler to a control event directly within the XAML code editor. To accomplish this you simply type the name of the event you want to handle (events are recognizable within IntelliSense with the Lightning icon) and then press Tab when IntelliSense shows the <New Event Handler> pop-up command (see Figure 31.11 for details).

Figure 31.11 Generating a new event handler with IntelliSense.

This generates an event handler stub in your code-behind file. Continuing ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.