SetHandler Method
Description
Enables event handling for a XAML object which links XAML events with a Subroutine or Function in code.
Syntax
Public Sub SetHandler( _
ByVal [Handler](#) As Object _
)
Parameters
- Handler: Reference to the parent object.
Remarks
SetHandler enables event handling for a XAML object. This will link XAML events with a Subroutine or Function in code (VB, C#, etc.).
Any XML Markup that is in the CheckBox, Button, RadioButton, Label, or MarkupLabel control's Caption property will be translated to viewable text. To enable event handling for a XAML object in one of the controls mentioned above, call SetHandler. With SetHandler, you only need to specify the Handler of the control, and all function names will be calculated from Markup.
In the sample below, the "HyperClick" and "Hyperlink_MouseRightButtonUpEvent" subroutines are used to handle the Click and MouseRightButtonUp events of the hyperlink.
Connecting XML events to your code can be very useful if using the MarkupLabel control to create a full-page application using XML. For example, clicking on hyperlinks and buttons, mouse overs, etc.
Example
Catching the Click and RightMouseUp event in Markup for a Hyperlink shows how to catch the Click and RightMouseUp event in Markup for a Hyperlink. In this case, the text is in the Caption of a MarkupLabel control.
Public Sub HyperClick(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs)
Dim tempHL As MarkupHyperlink
Set tempHL = Sender
MsgBox tempHL.Tag + " was clicked"
End Sub
Public Sub Hyperlink_MouseRightButtonUpEvent(ByVal Sender As MarkupObject, ByVal Args As MarkupRoutedEventArgs)
Dim tempHL As MarkupHyperlink
Set tempHL = Sender
MsgBox tempHL.Tag + " has been right clicked"
End Sub
MarkupLabel2.MarkupContext.SetHandler Me
MarkupLabel2.Caption = "Text with Hyperlink"
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.