RoutedCommand.Execute(Object, IInputElement) Yöntem

Tanım

geçerli komut hedefinde öğesini RoutedCommand yürütür.

public:
 void Execute(System::Object ^ parameter, System::Windows::IInputElement ^ target);
[System.Security.SecurityCritical]
public void Execute (object parameter, System.Windows.IInputElement target);
public void Execute (object parameter, System.Windows.IInputElement target);
[<System.Security.SecurityCritical>]
member this.Execute : obj * System.Windows.IInputElement -> unit
member this.Execute : obj * System.Windows.IInputElement -> unit
Public Sub Execute (parameter As Object, target As IInputElement)

Parametreler

parameter
Object

İşleyiciye geçirilecek kullanıcı tanımlı parametre.

target
IInputElement

Komut işleyicilerini aramaya başlayabileceğiniz öğe.

Öznitelikler

Özel durumlar

Örnekler

Aşağıdaki örnek, örneğin özel bir uygulamasından alınmalıdır ICommandSource .

this.Command bu örnekte, üzerindeki Command özelliğidir ICommandSource. Komut null değilse, komutu bir RoutedCommandöğesine yayınlanır. Bu bir RoutedCommandExecute ise ve geçirilirken CommandTarget yöntemi çağrılırCommandParameter. Komut bir RoutedCommanddeğilse, öğesine yayınlanır ICommand ve Execute yöntemi geçirilirken çağrılır CommandParameter.

// If Command is defined, moving the slider will invoke the command;
// Otherwise, the slider will behave normally.
protected override void OnValueChanged(double oldValue, double newValue)
{
    base.OnValueChanged(oldValue, newValue);

    if (this.Command != null)
    {
        RoutedCommand command = Command as RoutedCommand;

        if (command != null)
        {
            command.Execute(CommandParameter, CommandTarget);
        }
        else
        {
            ((ICommand)Command).Execute(CommandParameter);
        }
    }
}
' If Command is defined, moving the slider will invoke the command;
' Otherwise, the slider will behave normally.
Protected Overrides Sub OnValueChanged(ByVal oldValue As Double, ByVal newValue As Double)
    MyBase.OnValueChanged(oldValue, newValue)

    If Me.Command IsNot Nothing Then
        Dim command As RoutedCommand = TryCast(Me.Command, RoutedCommand)

        If command IsNot Nothing Then
            command.Execute(CommandParameter, CommandTarget)
        Else
            CType(Me.Command, ICommand).Execute(CommandParameter)
        End If
    End If
End Sub

Açıklamalar

yürüten RoutedCommand gerçek mantık yöntemlerinde Execute yer almaz. ExecutePreviewExecutedExecuted ile bir nesne CommandBindingarayan öğe ağacından tünel oluşturan ve olayları tetikler. Bunun RoutedCommand için bir CommandBinding bulunursa, ExecutedRoutedEventHandler iliştirilen CommandBinding çağrılır. Bu işleyiciler, öğesini gerçekleştiren RoutedCommandprogramlama mantığını sağlar.

PreviewExecuted ve Executed olayları üzerinde CommandTargetoluşturulur. CommandTarget öğesinde PreviewExecutedICommandSourceayarlanmadıysa ve Executed olayları klavye odağıyla öğesinde tetiklenir.

Şunlara uygulanır