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 . 처리기는 의 Command 속성을 ExecutedRoutedEventArgs 확인하여 호출할 메서드를 결정합니다.

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

설명

이벤트와 연결된 명령은 형식이 알려진 경우 의 특정 구현 ICommand( RoutedCommand예: )으로 캐스팅할 수 있습니다.

적용 대상

추가 정보