CommandBinding CommandBinding CommandBinding CommandBinding Class

定义

RoutedCommand 绑定到实现该命令的事件处理程序。Binds a RoutedCommand to the event handlers that implement the command.

public ref class CommandBinding
public class CommandBinding
type CommandBinding = class
Public Class CommandBinding
继承
CommandBindingCommandBindingCommandBindingCommandBinding

注解

一个CommandBinding将与命令相关联PreviewExecuted / ExecutedPreviewCanExecute / CanExecute事件的实现,并确定命令的状态。A CommandBinding associates a command with the PreviewExecuted/Executed and PreviewCanExecute/CanExecute events which implement and determine the status of the command.

ExecuteCanExecute方法RoutedCommand调用时, PreviewExecuted / Executed或者PreviewCanExecute / CanExecute命令目标上引发事件。When the Execute or CanExecute method of a RoutedCommand is called, the PreviewExecuted/Executed or the PreviewCanExecute/CanExecute events are raised on the command target. 如果命令目标有CommandBinding命令,调用相应的处理程序。If the command target has a CommandBinding for the command, the appropriate handlers are called. 如果命令目标不具有CommandBinding命令,事件将发送通过元素树具有的元素,直到CommandBinding找到。If the command target does not have a CommandBinding for the command, the events are routed through the element tree until an element that has a CommandBinding is found.

一个CommandBinding有限使用与ICommand不是RoutedCommandA CommandBinding has limited use with an ICommand that is not a RoutedCommand. 这是因为CommandBinding绑定到命令ExecutedRoutedEventHandlerCanExecuteRoutedEventHandler其侦听ExecutedCanExecute路由事件的时引发ExecuteCanExecute方法RoutedCommand调用。This is because a CommandBinding binds the command to the ExecutedRoutedEventHandler and the CanExecuteRoutedEventHandler which listen to the Executed and CanExecute routed events which are raised when the Execute and CanExecute method of the RoutedCommand are called.

构造函数

CommandBinding() CommandBinding() CommandBinding() CommandBinding()

初始化 CommandBinding 类的新实例。Initializes a new instance of the CommandBinding class.

CommandBinding(ICommand) CommandBinding(ICommand) CommandBinding(ICommand) CommandBinding(ICommand)

使用指定的 CommandBinding 初始化 ICommand 类的新实例。Initializes a new instance of the CommandBinding class by using the specified ICommand.

CommandBinding(ICommand, ExecutedRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler)

使用指定的 CommandBinding 和指定的 ICommand 事件处理程序初始化 Executed 类的新实例。Initializes a new instance of the CommandBinding class by using the specified ICommand and the specified Executed event handler.

CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler)

使用指定的 CommandBinding 和指定的 ICommandExecuted 事件处理程序初始化 CanExecute 类的新实例。Initializes a new instance of the CommandBinding class by using the specified ICommand and the specified Executed and CanExecute event handlers.

属性

Command Command Command Command

获取或设置与此 CommandBinding 关联的 ICommandGets or sets the ICommand associated with this CommandBinding.

事件

CanExecute CanExecute CanExecute CanExecute

在与此 CommandBinding 关联的命令开始检查能否对命令目标执行该命令时发生。Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the command target.

Executed Executed Executed Executed

执行与此 CommandBinding 相关联的命令时发生。Occurs when the command associated with this CommandBinding executes.

PreviewCanExecute PreviewCanExecute PreviewCanExecute PreviewCanExecute

在与此 CommandBinding 关联的命令开始检查能否对当前命令目标执行该命令时发生。Occurs when the command associated with this CommandBinding initiates a check to determine whether the command can be executed on the current command target.

PreviewExecuted PreviewExecuted PreviewExecuted PreviewExecuted

执行与此 CommandBinding 相关联的命令时发生。Occurs when the command associated with this CommandBinding executes.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于

另请参阅