RoutedCommand 類別

定義

定義命令,這個命令實作 ICommand 和透過項目樹狀進行遞送。

public ref class RoutedCommand : System::Windows::Input::ICommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public class RoutedCommand : System.Windows.Input.ICommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public class RoutedCommand : System.Windows.Input.ICommand
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
type RoutedCommand = class
    interface ICommand
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
type RoutedCommand = class
    interface ICommand
Public Class RoutedCommand
Implements ICommand
繼承
RoutedCommand
衍生
屬性
實作

備註

Execute上的 RoutedCommandCanExecute 方法不包含命令的應用程式邏輯,如同一般 ICommand的情況一樣,這些方法會引發事件來周遊具有 的物件CommandBinding樹狀結構。 附加至的 CommandBinding 事件處理程式包含命令邏輯。

方法 ExecutePreviewExecuted 引發和 Executed 事件。 方法 CanExecutePreviewCanExecute 引發和 CanExecute 事件。

XAML 屬性用法

<object-property="predefined-command-name"/>
-or-
<object-property="predefined-class-name.predefined-command-name"/>
-or-
<object-property="{custom-class-name.custom-command-name}"/>

XAML 值

predefined-class-name
其中一個預先定義的命令類別。

predefined-command-name
其中一個預先定義的命令。

custom-class-name
包含自訂命令的自定義類別。 自定義類別通常需要 xlmns 前置詞對應。 如需詳細資訊,請參閱 WPF XAML 的 XAML 命名空間和命名空間對應

custom-command-name
自訂命令。

建構函式

RoutedCommand()

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

RoutedCommand(String, Type)

使用指定的名稱和擁有者類別,初始化 RoutedCommand 類別的新執行個體。

RoutedCommand(String, Type, InputGestureCollection)

使用指定的名稱、擁有者型別和筆勢集合,初始化 RoutedCommand 類別的新執行個體。

屬性

InputGestures

取得與這個命令關聯之 InputGesture 物件的集合。

Name

取得命令的名稱。

OwnerType

取得會以命令註冊的型別。

方法

CanExecute(Object, IInputElement)

判斷這個 RoutedCommand 是否能在其目前狀態中執行。

Equals(Object)

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

(繼承來源 Object)
Execute(Object, IInputElement)

在目前的命令目標上執行 RoutedCommand

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

事件

CanExecuteChanged

發生於命令管理員偵測命令來源時。 這些變更通常會影響命令是否應在目前命令目標上執行。

明確介面實作

ICommand.CanExecute(Object)

如需這個成員的說明,請參閱 CanExecute(Object)

ICommand.Execute(Object)

如需這個成員的說明,請參閱 Execute(Object)

適用於

另請參閱