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.

使用RegisterClassCommandBinding向類別CommandBinding註冊, 而不是實例。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)

將指定的 CanExecuteRoutedEventHandler 從指定的項目中斷連結。Detaches the specified CanExecuteRoutedEventHandler from the specified element.

RemoveExecutedHandler(UIElement, ExecutedRoutedEventHandler)

將指定的 ExecutedRoutedEventHandler 從指定的項目中斷連結。Detaches the specified ExecutedRoutedEventHandler from the specified element.

RemovePreviewCanExecuteHandler(UIElement, CanExecuteRoutedEventHandler)

將指定的 CanExecuteRoutedEventHandler 從指定的項目中斷連結。Detaches the specified CanExecuteRoutedEventHandler from the specified element.

RemovePreviewExecutedHandler(UIElement, ExecutedRoutedEventHandler)

將指定的 ExecutedRoutedEventHandler 從指定的項目中斷連結。Detaches the specified ExecutedRoutedEventHandler from the specified element.

ToString()

傳回代表目前物件的字串。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.

適用於

另請參閱