mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 00:56:03 +02:00
* Add article, redirects, toc * Update dotnet-desktop-guide/net/wpf/events/how-to-create-a-custom-routed-event.md Co-authored-by: Andy (Steve) De George <[email protected]> * Update dotnet-desktop-guide/net/wpf/events/snippets/how-to-create-a-custom-routed-event/csharp/CodeSample.csproj Co-authored-by: Andy (Steve) De George <[email protected]> * Update dotnet-desktop-guide/net/wpf/events/snippets/how-to-create-a-custom-routed-event/vb/CodeSampleVb.vbproj Co-authored-by: Andy (Steve) De George <[email protected]> * Update dotnet-desktop-guide/net/wpf/events/snippets/how-to-create-a-custom-routed-event/WpfControlLibraryCsharp/WpfControlLibrary.csproj Co-authored-by: Andy (Steve) De George <[email protected]> * Use local project references Co-authored-by: Andy (Steve) De George <[email protected]>
40 lines
1.7 KiB
VB.net
40 lines
1.7 KiB
VB.net
Namespace CodeSampleVb
|
|
Partial Public Class MainWindow
|
|
Inherits Window
|
|
|
|
Public Sub New()
|
|
InitializeComponent()
|
|
|
|
' Assign an event handler to CustomButton using the AddHandler statement.
|
|
' AddHandler customButton.ConditionalClick, AddressOf Handler_ConditionalClick
|
|
|
|
' Assign an event handler to CustomButton using the AddHandler method.
|
|
' customButton.[AddHandler](WpfControlVb.CustomButton.ConditionalClickEvent,
|
|
' New RoutedEventHandler(AddressOf Handler_ConditionalClick))
|
|
|
|
' Assign an event handler to StackPanel1 using the AddHandler method.
|
|
' StackPanel1.[AddHandler](WpfControlVb.CustomButton.ConditionalClickEvent,
|
|
' New RoutedEventHandler(AddressOf Handler_ConditionalClick))
|
|
End Sub
|
|
|
|
'<EventHandler>
|
|
' The ConditionalClick event handler.
|
|
Private Sub Handler_ConditionalClick(sender As Object, e As RoutedEventArgs)
|
|
|
|
Dim sourceName As String = CType(e.Source, FrameworkElement).Name
|
|
Dim senderName As String = CType(sender, FrameworkElement).Name
|
|
|
|
Debug.WriteLine($"Routed event handler attached to {senderName}, " +
|
|
$"triggered by the ConditionalClick routed event raised on {sourceName}.")
|
|
|
|
End Sub
|
|
|
|
' Debug output when CustomButton is clicked:
|
|
' Routed event handler attached to CustomButton,
|
|
' triggered by the ConditionalClick routed event raised on CustomButton.
|
|
' Routed event handler attached to StackPanel1,
|
|
' triggered by the ConditionalClick routed event raised on CustomButton.
|
|
'</EventHandler>
|
|
End Class
|
|
End Namespace
|