CommandBinding 類別

定義

繫結 RoutedCommand 至實作此命令的事件處理常式。

public ref class CommandBinding
public class CommandBinding
type CommandBinding = class
Public Class CommandBinding
繼承
CommandBinding

備註

CommandBinding建立命令與 和 PreviewCanExecute/CanExecute 事件的關聯,PreviewExecuted/Executed以實作和判斷命令的狀態。

Execute呼叫 的 RoutedCommandCanExecute 方法時,PreviewExecuted/Executed會在命令目標上引發 或 PreviewCanExecute/CanExecute 事件。 如果命令目標具有 CommandBinding 命令的 ,則會呼叫適當的處理程式。 如果命令目標沒有 CommandBinding 命令的 ,事件會透過專案樹狀結構路由傳送,直到找到具有 CommandBinding 的項目為止。

CommandBinding的用法ICommand有限,但不是 RoutedCommand。 這是因為 會將 CommandBinding 命令系結至 ExecutedRoutedEventHandler ,以及CanExecuteRoutedEventHandler接聽 Executed 呼叫 和 CanExecute 方法時Execute引發的 RoutedCommandCanExecute 路由事件。

建構函式

CommandBinding()

初始化 CommandBinding 類別的新執行個體。

CommandBinding(ICommand)

使用指定的 CommandBinding 來初始化 ICommand 類別的新執行個體。

CommandBinding(ICommand, ExecutedRoutedEventHandler)

使用指定的 CommandBinding 和指定的 ICommand 事件處理常式,初始化 Executed 類別的新執行個體。

CommandBinding(ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler)

使用指定的 CommandBinding,和指定的 ICommandExecuted 事件處理常式,初始化 CanExecute 類別的新執行個體。

屬性

Command

取得或設定與這個 ICommand 關聯的 CommandBinding

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

事件

CanExecute

與此 CommandBinding 相關聯的命令開始檢查是否可在命令目標執行該命令時發生。

Executed

與此 CommandBinding 相關聯的命令執行時發生。

PreviewCanExecute

與此 CommandBinding 相關聯的命令開始檢查是否可在目前的命令目標執行該命令時發生。

PreviewExecuted

與此 CommandBinding 相關聯的命令執行時發生。

適用於

另請參閱