Skip to content

SetMethod Method

Description

Links a XAML event with a Subroutine or Function in code.

Syntax

Public Sub SetMethod( _
    ByVal [Handler](#) As Object, _
    ByVal [Method](#) As String _
)

Parameters

  • Handler: Reference to the parent object.
  • Method: Name of the Subroutine or Function in code to link to a XAML event.

Remarks

SetMethod of the MarkupContext object is used to connect method calls in XML Markup with actual methods, functions, and events in your code.

For example (see code sample below), using SetMethod, the BackstageButton control can handle events called from XML Markup with Markup enabled.

When EnableMarkup is true, any XML Markup that is in the Label control's Caption property will be translated to viewable text. Using SetMethod, an external method or event can be called from the XML inside the BackStageButton control's Caption. In the sample below, the "Hyperlink_Click" subroutine is "connected" to the XML Hyperlink Click event using SetMethod.

Connecting XML events to your code can be very useful as shown in the example below.

Example

Public Sub Hyperlink_Click(Reserved1 As Object, Reserved2 As Object)  
    MsgBox "Clicked"  
End Sub  

Private Sub Form_Load()  
    BackStageButton1.EnableMarkup = True  
    BackStageButton1.MarkupContext.SetMethod Me, "Hyperlink_Click"  
    BackStageButton1.Caption = "Click this link"  
End Sub

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.