RoutedCommand.Execute(Object, IInputElement) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
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şleyicilerinin aranmaya başlandığı öğe.
- Öznitelikler
Özel durumlar
targetveya UIElementdeğildirContentElement.
Ö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 öğesine RoutedCommandyayınlanır. Bu bir RoutedCommandExecute ise, ve geçirme CommandTargetCommandParameteryöntemi olarak adlandırılır. 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. Execute PreviewExecuted ile bir nesne Executedarayan öğe ağacında tünel ve kabarcık oluşturan ve CommandBinding olaylarını yükseltir. Bunun CommandBinding için bir RoutedCommand 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 ICommandSourcePreviewExecutedayarlanmadıysa ve Executed olayları klavye odağıyla öğesinde oluşturulur.