RoutedUICommand 類別

定義

定義經由項目樹狀目錄傳送並包含文字屬性的 ICommandDefines an ICommand that is routed through the element tree and contains a text property.

public ref class RoutedUICommand : System::Windows::Input::RoutedCommand
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public class RoutedUICommand : System.Windows.Input.RoutedCommand
type RoutedUICommand = class
    inherit RoutedCommand
Public Class RoutedUICommand
Inherits RoutedCommand
繼承
RoutedUICommand
屬性

備註

RoutedUICommandRoutedCommand 之間的Text差異在於包含屬性。 RoutedUICommandThe difference between a RoutedUICommand and RoutedCommand is that RoutedUICommand includes a Text property.

Execute CanExecute的和方法不包含命令的命令邏輯, 如同一般ICommand的情況。 RoutedCommandThe Execute and CanExecute methods on a RoutedCommand do not contain the command logic for the command, as is the case with a typical ICommand. 這些方法會引發事件, 以遍歷專案樹狀結構來尋找具有的CommandBinding物件。These methods raise events that traverse the element tree looking for an object with a CommandBinding. 附加至的CommandBinding事件處理常式會包含命令邏輯。The event handlers attached to the CommandBinding contain the command logic.

方法會PreviewExecuted引發和Executed事件。 ExecuteThe Execute method raises the PreviewExecuted and Executed events. 方法會PreviewCanExecute引發和CanExecute事件。 CanExecuteThe CanExecute method raises the PreviewCanExecute and CanExecute events.

XAML Attribute UsageXAML Attribute Usage

<object property="predefinedCommandName"/>  
- or -  
<object property="predefinedClassName.predefinedCommandName"/>  
- or -  
<object property="{x:Static customClassName.customCommandName}"/>  
  

XAML 值XAML Values

predefinedClassNamepredefinedClassName
其中一個預先定義的命令類別。One of the predefined command classes.

predefinedCommandNamepredefinedCommandName
其中一個預先定義的命令。One of the predefined commands.

prefixprefix
對應xlmns customClassName的前置詞。customCommandName.NET.NET類別。The xlmns prefix that maps customClassName.customCommandName to the .NET.NET class. 如需詳細資訊, 請參閱WPF xaml 的 Xaml 命名空間和命名空間對應For more information, see XAML Namespaces and Namespace Mapping for WPF XAML.

customClassNamecustomClassName
包含自訂命令的自訂類別。A custom class that contains the custom command.

customCommandNamecustomCommandName
自訂命令。A custom command.

建構函式

RoutedUICommand()

初始化 RoutedUICommand 類別的新執行個體。Initializes a new instance of the RoutedUICommand class.

RoutedUICommand(String, String, Type)

使用指定的描述文字、宣告名稱和擁有者類型,初始化 RoutedUICommand 類別的新執行個體。Initializes a new instance of the RoutedUICommand class, using the specified descriptive text, declared name, and owner type.

RoutedUICommand(String, String, Type, InputGestureCollection)

使用指定的描述文字、宣告名稱、擁有者類型和輸入筆勢,初始化 RoutedUICommand 類別的新執行個體。Initializes a new instance of the RoutedUICommand class, using the specified descriptive text, declared name, owner type, and input gestures.

屬性

InputGestures

取得與這個命令關聯之 InputGesture 物件的集合。Gets the collection of InputGesture objects that are associated with this command.

(繼承來源 RoutedCommand)
Name

取得命令的名稱。Gets the name of the command.

(繼承來源 RoutedCommand)
OwnerType

取得會以命令註冊的型別。Gets the type that is registered with the command.

(繼承來源 RoutedCommand)
Text

取得或設定描述這個命令的文字。Gets or sets the text that describes this command.

方法

CanExecute(Object, IInputElement)

判斷這個 RoutedCommand 是否能在其目前狀態中執行。Determines whether this RoutedCommand can execute in its current state.

(繼承來源 RoutedCommand)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

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

在目前的命令目標上執行 RoutedCommandExecutes the RoutedCommand on the current command target.

(繼承來源 RoutedCommand)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

CanExecuteChanged

發生於命令管理員偵測命令來源時。Occurs when changes to the command source are detected by the command manager. 這些變更通常會影響命令是否應在目前命令目標上執行。These changes often affect whether the command should execute on the current command target.

(繼承來源 RoutedCommand)

明確介面實作

ICommand.CanExecute(Object)

如需這個成員的說明,請參閱 CanExecute(Object)For a description of this members, see CanExecute(Object).

(繼承來源 RoutedCommand)
ICommand.Execute(Object)

如需這個成員的說明,請參閱 Execute(Object)For a description of this members, see Execute(Object).

(繼承來源 RoutedCommand)

適用於

另請參閱