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

備註

ACommandBinding產生關聯的命令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 / ExecutedPreviewCanExecute / 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.

ACommandBinding的使用僅限於使用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

取得或設定與這個 ICommand 關聯的 CommandBindingGets 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 的淺層複本 (Shallow Copy)。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)

適用於

另請參閱