ExecutedRoutedEventArgs.Command Tulajdonság

Definíció

Lekéri a meghívott parancsot.

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

Tulajdonság értéke

Az eseményhez társított parancs.

Példák

Az alábbi példa egy több parancsot kezelő parancsot ExecutedRoutedEventHandler hoz létre. A kezelő ellenőrzi a Command tulajdonságot a ExecutedRoutedEventArgs meghívandó metódus meghatározásához.

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

Megjegyzések

Az eseményhez társított parancs a típus ismert típusának adott implementációjára ICommandvethető ki, például egy RoutedCommand.

A következőre érvényes:

Lásd még