ExecutedRoutedEventArgs.Command プロパティ

定義

呼び出されたコマンドを取得します。

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

プロパティ値

このイベントに関連付けられているコマンド。

次の例では、複数のコマンドを処理する を ExecutedRoutedEventHandler 作成します。 ハンドラーは、 の プロパティExecutedRoutedEventArgsCommandチェックして、呼び出すメソッドを決定します。

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

注釈

イベントに関連付けられているコマンドは、 の特定のICommandRoutedCommand実装 (型がわかっている場合は など) にキャストできます。

適用対象

こちらもご覧ください