ExecutedRoutedEventArgs.Command Proprietà

Definizione

Ottiene il comando che è stato richiamato.

public:
 property System::Windows::Input::ICommand ^ Command { System::Windows::Input::ICommand ^ get(); };
public System.Windows.Input.ICommand Command { get; }
member this.Command : System.Windows.Input.ICommand
Public ReadOnly Property Command As ICommand

Valore della proprietà

Comando associato a questo evento.

Esempio

Nell'esempio seguente viene creato un oggetto ExecutedRoutedEventHandler che gestisce più comandi. Il gestore controlla la proprietà nell'oggetto CommandExecutedRoutedEventArgs per determinare quale metodo chiamare.

private void ExecutedDisplayCommand(object sender,
    ExecutedRoutedEventArgs e)
{
    RoutedCommand command = e.Command as RoutedCommand;

    if(command != null)
    {
        if(command == MediaCommands.Pause)
        {
               MyPauseMethod();
        }
        if(command == MediaCommands.Play)
        {
               MyPlayMethod();
        }
        if(command == MediaCommands.Stop)
        {
               MyStopMethod();
        }
    }
}
Private Sub ExecutedDisplayCommand(ByVal sender As Object, ByVal e As ExecutedRoutedEventArgs)
    Dim command As RoutedCommand = TryCast(e.Command, RoutedCommand)

    If command IsNot Nothing Then
        If command Is MediaCommands.Pause Then
               MyPauseMethod()
        End If
        If command Is MediaCommands.Play Then
               MyPlayMethod()
        End If
        If command Is MediaCommands.Stop Then
               MyStopMethod()
        End If
    End If
End Sub

Commenti

Il comando associato all'evento può essere eseguito il cast per l'implementazione specifica di ICommand, ad esempio , RoutedCommandse il tipo è noto.

Si applica a

Vedi anche