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

備註

CommandBindingPreviewCanExecute命令PreviewExecuted 與執行和CanExecute判斷命令狀態的/和事件產生關聯。 Executed /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是因為會將命令系結ExecutedRoutedEventHandler至和CanExecuteRoutedEventHandler ,而後者會接聽ExecutedCanExecute路由事件(當Execute 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

取得或設定與這個 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)

適用於

另請參閱