CommandBinding.Executed Événement
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Se produit lorsque la commande associée à cette CommandBinding opération s’exécute.
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
Type d'événement
Exemples
L’exemple suivant crée un CommandBinding mappage d’un ExecutedRoutedEventHandler gestionnaire et d’un CanExecuteRoutedEventArgs gestionnaire à la Open commande.
<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)
L’exemple suivant illustre la ExecutedRoutedEventHandler création d’une MessageBox commande lors de l’exécution de la commande.
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
Remarques
Lorsqu’une RoutedCommand exécution est exécutée, elle déclenche l’événement PreviewExecuted sur la cible de commande. Si l’événement PreviewExecuted n’est pas géré, l’événement Executed est déclenché sur la cible de commande. Si la cible de commande a une CommandBinding pour la commande spécifique, le Executed gestionnaire pour celui-ci CommandBinding est appelé. Si la cible de commande n’a pas de CommandBinding commande spécifique, l’événement Executed se déclenche dans l’arborescence d’éléments recherchant un élément associé CommandBinding à la commande. Si une CommandBinding valeur est introuvable, la commande n’est pas gérée.
Informations sur les événements routés
| Élément | Valeur |
|---|---|
| Champ d’identificateur | ExecutedEvent |
| Stratégie de routage | Bouillonnant |
| Déléguer | ExecutedRoutedEventHandler |
- L’événement de tunneling correspondant est PreviewExecuted.