Bagikan melalui


ExecutedRoutedEventArgs.Command Properti

Definisi

Mendapatkan perintah yang dipanggil.

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

Nilai Properti

Perintah yang terkait dengan kejadian ini.

Contoh

Contoh berikut membuat yang ExecutedRoutedEventHandler menangani beberapa perintah. Handler memeriksa Command properti pada ExecutedRoutedEventArgs untuk menentukan metode mana yang akan dipanggil.

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

Keterangan

Perintah yang terkait dengan peristiwa dapat ditransmisikan ke implementasi tertentu dari ICommand, seperti RoutedCommand, jika jenisnya diketahui.

Berlaku untuk

Lihat juga