CommandBinding.Executed Událost

Definice

Vyvolá se při spuštění příkazu přidruženého k tomuto CommandBinding příkazu.

public:
 event System::Windows::Input::ExecutedRoutedEventHandler ^ Executed;
public event System.Windows.Input.ExecutedRoutedEventHandler Executed;
member this.Executed : System.Windows.Input.ExecutedRoutedEventHandler 
Public Custom Event Executed As ExecutedRoutedEventHandler 
Public Event Executed As ExecutedRoutedEventHandler 

Event Type

Příklady

Následující příklad vytvoří objekt CommandBinding , který mapuje obslužnou rutinu ExecutedRoutedEventHandlerCanExecuteRoutedEventArgs a na Open příkaz .

<Window.CommandBindings>
  <CommandBinding Command="ApplicationCommands.Open"
                  Executed="OpenCmdExecuted"
                  CanExecute="OpenCmdCanExecute"/>
</Window.CommandBindings>
// Creating CommandBinding and attaching an Executed and CanExecute handler
CommandBinding OpenCmdBinding = new CommandBinding(
    ApplicationCommands.Open,
    OpenCmdExecuted,
    OpenCmdCanExecute);

this.CommandBindings.Add(OpenCmdBinding);
' Creating CommandBinding and attaching an Executed and CanExecute handler
Dim OpenCmdBinding As New CommandBinding(ApplicationCommands.Open, AddressOf OpenCmdExecuted, AddressOf OpenCmdCanExecute)

Me.CommandBindings.Add(OpenCmdBinding)

Následující příklad ukazuje, ExecutedRoutedEventHandler který při spuštění příkazu vytvoří MessageBox .

void OpenCmdExecuted(object target, ExecutedRoutedEventArgs e)
{
    String command, targetobj;
    command = ((RoutedCommand)e.Command).Name;
    targetobj = ((FrameworkElement)target).Name;
    MessageBox.Show("The " + command +  " command has been invoked on target object " + targetobj);
}
Private Sub OpenCmdExecuted(ByVal sender As Object, ByVal e As ExecutedRoutedEventArgs)
    Dim command, targetobj As String
    command = CType(e.Command, RoutedCommand).Name
    targetobj = CType(sender, FrameworkElement).Name
    MessageBox.Show("The " + command + " command has been invoked on target object " + targetobj)
End Sub

Poznámky

RoutedCommand Při spuštění vyvolá PreviewExecuted událost v cíli příkazu. Pokud událost PreviewExecuted není zpracována, Executed událost je vyvolána na cílovém příkazu. Pokud cíl příkazu obsahuje CommandBinding pro konkrétní příkaz , Executed je volána obslužná rutina pro CommandBinding tento příkaz. Pokud cíl příkazu nemá CommandBinding objekt pro tento konkrétní příkaz, Executed událost vyvolá bublinu ve stromu prvků a vyhledá prvek, který má CommandBinding přidružený k příkazu . CommandBinding Pokud se nenajde, příkaz se nezpracuje.

Informace o směrované události

Pole Identifikátor ExecutedEvent
Strategie směrování Bublající
Delegát ExecutedRoutedEventHandler

Platí pro

Viz také