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命令PreviewCanExecute / 与实现和CanExecute确定命令状态的和事件关联。Executed PreviewExecuted /A CommandBinding associates a command with the PreviewExecuted/Executed and PreviewCanExecute/CanExecute events which implement and determine the status of the command.

CanExecute PreviewCanExecute调用的或方法RoutedCommand时, PreviewExecuted 将在/命令目标上引发或CanExecute事件。 Executed / ExecuteWhen 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.

与不是的使用有限。 RoutedCommand CommandBinding ICommandA CommandBinding has limited use with an ICommand that is not a RoutedCommand. 这是因为, CommandBinding将命令绑定ExecutedRoutedEventHandlerCanExecuteRoutedEventHandler Executed Execute和路由事件,这些事件在的和CanExecute方法 CanExecute 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)

适用于

另请参阅