ICommandSource.CommandTarget 属性

定义

在其上执行该命令的对象。The object that the command is being executed on.

public:
 property System::Windows::IInputElement ^ CommandTarget { System::Windows::IInputElement ^ get(); };
public System.Windows.IInputElement CommandTarget { get; }
member this.CommandTarget : System.Windows.IInputElement
Public ReadOnly Property CommandTarget As IInputElement

属性值

IInputElement

在其上执行该命令的对象。The object that the command is being executed on.

注解

在 Windows Presentation Foundation 命令系统中, CommandTarget 上的属性 ICommandSource 仅在为时才适用 ICommand RoutedCommandIn the Windows Presentation Foundation commanding system, the CommandTarget property on a ICommandSource is only applicable when the ICommand is a RoutedCommand. 如果在 CommandTarget 上设置, ICommandSource 并且相应的命令不是,则 RoutedCommand 忽略命令目标。If the CommandTarget is set on a ICommandSource and the corresponding command is not a RoutedCommand, the command target is ignored.

当与一起使用时 RoutedCommand ,命令目标是 Executed 引发和事件的对象 CanExecuteWhen used with a RoutedCommand, the command target is the object on which the Executed and CanExecute events are raised. 如果 CommandTarget 未设置该属性,则具有键盘焦点的元素将用作目标。If the CommandTarget property is not set, the element with keyboard focus will be used as the target.

适用于

另请参阅