8.2. Common Event ReferenceElements deriving from UIElement inherit a set of common events. Events are used in XAML to specify the codebehind handler that will be executed when the specified event is raised. All events can be assigned a codebehind handler using the following syntax: <Element Name="ElementName" EventName="CodeBehindHandler" /> Elements specifying a codebehind handler must declare the Name attribute in order to be referenced in the codebehind class. Examples 8-2 and 8-3 demonstrate the event-handling code in C# and VisualBasic, respectively, which is executed when the mouse cursor enters or leaves the Button declared in Example 8-4. Example 8-2. C# implementation of event handlers
Example 8-3. VisualBasic implementation of event handlers
Example 8-4. XAML declaration of event handlers for Button
The following events are common to all UIElement-derived elements. Events specific to the element are listed with the element description. Events are fully detailed in Chapter 12, along with a more thorough exploration of the event subsystem.
|