CommandManager 类

定义

提供为类所有者和命令注册 CommandBindingInputBinding 对象、添加和移除命令事件处理程序的与命令有关的实用程序方法,并提供查询命令状态的服务。Provides command related utility methods that register CommandBinding and InputBinding objects for class owners and commands, add and remove command event handlers, and provides services for querying the status of a command.

public ref class CommandManager sealed
public sealed class CommandManager
type CommandManager = class
Public NotInheritable Class CommandManager
继承
CommandManager

注解

CommandManager负责管理路由命令。The CommandManager is responsible for managing routed commands. 有关命令的详细信息, 请参阅命令概述For more information about commanding, see Commanding Overview.

使用RegisterClassCommandBindingCommandBinding注册到类, 而不是实例。Use RegisterClassCommandBinding to register a CommandBinding to a class as opposed to an instance.

使用RegisterClassInputBindingInputBinding注册到类, 而不是实例。Use RegisterClassInputBinding to register an InputBinding to a class as opposed to an instance.

InvalidateRequerySuggested 方法强制 CommandManager 引发 RequerySuggested 事件。The InvalidateRequerySuggested method forces the CommandManager to raise the RequerySuggested event. RequerySuggested事件通知命令源查询它与之相关联的命令, 以确定是否可以执行该命令。The RequerySuggested event informs a command source to query the command it is associated with to determine whether or not the command can execute.

字段

CanExecuteEvent

标识 CanExecute 附加事件。Identifies the CanExecute attached event.

ExecutedEvent

标识 Executed 附加事件。Identifies the Executed attached event.

PreviewCanExecuteEvent

标识 PreviewCanExecute 附加事件。Identifies the PreviewCanExecute attached event.

PreviewExecutedEvent

标识 PreviewExecuted 附加事件。Identifies the PreviewExecuted attached event.

方法

AddCanExecuteHandler(UIElement, CanExecuteRoutedEventHandler)

将指定的 CanExecuteRoutedEventHandler 附加到指定的元素。Attaches the specified CanExecuteRoutedEventHandler to the specified element.

AddExecutedHandler(UIElement, ExecutedRoutedEventHandler)

将指定的 ExecutedRoutedEventHandler 附加到指定的元素。Attaches the specified ExecutedRoutedEventHandler to the specified element.

AddPreviewCanExecuteHandler(UIElement, CanExecuteRoutedEventHandler)

将指定的 CanExecuteRoutedEventHandler 附加到指定的元素。Attaches the specified CanExecuteRoutedEventHandler to the specified element.

AddPreviewExecutedHandler(UIElement, ExecutedRoutedEventHandler)

将指定的 ExecutedRoutedEventHandler 附加到指定的元素。Attaches the specified ExecutedRoutedEventHandler to the specified element.

Equals(Object)

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

(继承自 Object)
GetHashCode()

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

(继承自 Object)
GetType()

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

(继承自 Object)
InvalidateRequerySuggested()

强制 CommandManager 引发 RequerySuggested 事件。Forces the CommandManager to raise the RequerySuggested event.

MemberwiseClone()

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

(继承自 Object)
RegisterClassCommandBinding(Type, CommandBinding)

使用指定的类型注册 CommandBindingRegisters a CommandBinding with the specified type.

RegisterClassInputBinding(Type, InputBinding)

使用指定的类型注册指定的 InputBindingRegisters the specified InputBinding with the specified type.

RemoveCanExecuteHandler(UIElement, CanExecuteRoutedEventHandler)

从指定的元素分离指定的 CanExecuteRoutedEventHandlerDetaches the specified CanExecuteRoutedEventHandler from the specified element.

RemoveExecutedHandler(UIElement, ExecutedRoutedEventHandler)

从指定的元素分离指定的 ExecutedRoutedEventHandlerDetaches the specified ExecutedRoutedEventHandler from the specified element.

RemovePreviewCanExecuteHandler(UIElement, CanExecuteRoutedEventHandler)

从指定的元素分离指定的 CanExecuteRoutedEventHandlerDetaches the specified CanExecuteRoutedEventHandler from the specified element.

RemovePreviewExecutedHandler(UIElement, ExecutedRoutedEventHandler)

从指定的元素分离指定的 ExecutedRoutedEventHandlerDetaches the specified ExecutedRoutedEventHandler from the specified element.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

事件

RequerySuggested

CommandManager 检测可能更改要执行的命令的功能的条件时发生。Occurs when the CommandManager detects conditions that might change the ability of a command to execute.

附加事件

CanExecute

当调用 CanExecute(Object, IInputElement) 上的 RoutedCommand 方法并且未处理 PreviewCanExecute 事件时发生。Occurs when the CanExecute(Object, IInputElement) method on the RoutedCommand is called and the PreviewCanExecute event was not handled.

Executed

当调用 Execute(Object, IInputElement) 上的 RoutedCommand 方法并且未处理 PreviewExecuted 事件时发生。Occurs when the Execute(Object, IInputElement) method on the RoutedCommand is called and the PreviewExecuted event was not handled.

PreviewCanExecute

当调用 CanExecute(Object, IInputElement) 上的 RoutedCommand 方法时发生。Occurs when the CanExecute(Object, IInputElement) method on the RoutedCommand is called.

PreviewExecuted

当调用 Execute(Object, IInputElement) 上的 RoutedCommand 方法时发生。Occurs when the Execute(Object, IInputElement) method on the RoutedCommand is called.

适用于

另请参阅