WPF VB.Net Tutorial

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="commandWithHandler" Name="root">
  
  
                        Executed="OpenCmdExecuted"
                    CanExecute="OpenCmdCanExecute"/>
  

  
    
  

  
                Height="50" Width="200">
      Open (KeyBindings: Ctrl+R, Ctrl+0)
    
  


//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Input
Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub
    Private Sub OpenCmdExecuted(target As Object, e As ExecutedRoutedEventArgs)
      Dim command As [String], targetobj As [String]
      command = DirectCast(e.Command, RoutedCommand).Name
      targetobj = DirectCast(target, FrameworkElement).Name
      MessageBox.Show(command & " : " & targetobj)
    End Sub
    Private Sub OpenCmdCanExecute(sender As Object, e As CanExecuteRoutedEventArgs)
      e.CanExecute = True
    End Sub
  End Class
End Namespace