CommandBinding.Executed Událost

Definice

Nastane, když se spustí příkaz přidružený 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ří CommandBinding mapování ExecutedRoutedEventHandler a obslužnou rutinu CanExecuteRoutedEventArgs 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ý vytvoří MessageBox při spuštění příkazu.

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

Když se RoutedCommand spustí, vyvolá PreviewExecuted událost v cíli příkazu. PreviewExecuted Pokud událost není zpracována, Executed je událost vyvolána v cíli příkazu. Pokud má cíl CommandBinding příkazu pro konkrétní příkaz, obslužná rutina Executed pro tento CommandBinding příkaz je volána. Pokud cíl příkazu nemá CommandBinding pro tento konkrétní příkaz Executed , událost bubliny ve stromu elementů vyhledá prvek, který má CommandBinding přidružený k příkazu. Pokud se CommandBinding nenajde, příkaz se nezpracuje.

Informace o směrované události

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

Platí pro

Viz také