CanExecuteRoutedEventArgs.Command Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene il comando associato a questo evento.
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
Valore della proprietà
Comando . A meno che il comando non sia un comando personalizzato, si tratta in genere di un oggetto RoutedCommand. Non esiste alcun valore predefinito.
Esempio
Nell'esempio seguente viene creato un oggetto CanExecuteRoutedEventHandler che gestisce più comandi. Se la Command proprietà è uguale al Play comando e il metodo IsPlaying restituisce false, CanExecute è impostato su ; in caso contrario, CanExecute è impostato truesu false. Se la Command proprietà è uguale al Stop comando e il metodo IsPlaying restituisce true, CanExecute è impostato su ; in caso contrario, CanExecute è impostato truesu false.
private void CanExecuteDisplayCommand(object sender,
CanExecuteRoutedEventArgs e)
{
RoutedCommand command = e.Command as RoutedCommand;
if (command != null)
{
if (command == MediaCommands.Play)
{
if (!IsPlaying())
{
e.CanExecute = true;
}
else
{
e.CanExecute = false;
}
}
if (command == MediaCommands.Stop)
{
if (IsPlaying())
{
e.CanExecute = true;
}
else
{
e.CanExecute = false;
}
}
}
}
Private Sub CanExecuteDisplayCommand(ByVal sender As Object, ByVal e As CanExecuteRoutedEventArgs)
Dim command As RoutedCommand = TryCast(e.Command, RoutedCommand)
If command IsNot Nothing Then
If command Is MediaCommands.Play Then
If IsPlaying() = False Then
e.CanExecute = True
Else
e.CanExecute = False
End If
End If
If command Is MediaCommands.Stop Then
If IsPlaying() = True Then
e.CanExecute = True
Else
e.CanExecute = False
End If
End If
End If
End Sub
Commenti
Per altre informazioni sui comandi, vedere Panoramica dei comandi.