ExecutedRoutedEventArgs.Command Propiedad

Definición

Obtiene el comando invocado.

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

Valor de propiedad

Comando asociado a este evento.

Ejemplos

En el ejemplo siguiente se crea un ExecutedRoutedEventHandler objeto que controla varios comandos. El controlador comprueba la Command propiedad en para ExecutedRoutedEventArgs determinar a qué método se va a llamar.

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

Comentarios

El comando asociado al evento se puede convertir a la implementación específica de ICommand, como , RoutedCommandsi se conoce el tipo .

Se aplica a

Consulte también