RoutedUICommand RoutedUICommand RoutedUICommand RoutedUICommand Class

定义

定义一个在元素树中路由并包含一个文本属性的 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
继承
RoutedUICommandRoutedUICommandRoutedUICommandRoutedUICommand
属性

注解

之间的差异RoutedUICommandRoutedCommand在于RoutedUICommand包括Text属性。The difference between a RoutedUICommand and RoutedCommand is that RoutedUICommand includes a Text property.

ExecuteCanExecute上的方法RoutedCommand与典型情况一样,不包含该命令的命令逻辑ICommandThe Execute and CanExecute methods on a RoutedCommand do not contain the command logic for the command, as is the case with a typical ICommand. 这些方法会引发遍历元素树,以查找的对象的事件CommandBindingThese 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.

Execute方法将引发PreviewExecutedExecuted事件。The Execute method raises the PreviewExecuted and Executed events. CanExecute方法将引发PreviewCanExecuteCanExecute事件。The CanExecute method raises the PreviewCanExecute and CanExecute events.

XAML 属性用法XAML 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映射的前缀customClassNamecustomCommandName.NET.NET类。The xlmns prefix that maps customClassName.customCommandName to the .NET.NET class. 有关详细信息,请参阅XAML 命名空间和 WPF XAML Namespace 映射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() RoutedUICommand() RoutedUICommand()

初始化 RoutedUICommand 类的新实例。Initializes a new instance of the RoutedUICommand class.

RoutedUICommand(String, String, Type) RoutedUICommand(String, String, Type) RoutedUICommand(String, String, Type) 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(String, String, Type, InputGestureCollection) RoutedUICommand(String, String, Type, InputGestureCollection) 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 InputGestures InputGestures InputGestures

获取集合的InputGesture与此命令关联的对象。Gets the collection of InputGesture objects that are associated with this command.

(Inherited from RoutedCommand)
Name Name Name Name

获取命令的名称。Gets the name of the command.

(Inherited from RoutedCommand)
OwnerType OwnerType OwnerType OwnerType

获取已注册到该命令的类型。Gets the type that is registered with the command.

(Inherited from RoutedCommand)
Text Text Text Text

获取或设置描述该命令的文本。Gets or sets the text that describes this command.

方法

CanExecute(Object, IInputElement) CanExecute(Object, IInputElement) CanExecute(Object, IInputElement) CanExecute(Object, IInputElement)

确定是否这RoutedCommand可以在其当前状态下执行。Determines whether this RoutedCommand can execute in its current state.

(Inherited from RoutedCommand)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Execute(Object, IInputElement) Execute(Object, IInputElement) Execute(Object, IInputElement) Execute(Object, IInputElement)

执行RoutedCommand当前命令目标上。Executes the RoutedCommand on the current command target.

(Inherited from RoutedCommand)
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 的浅表副本。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)

事件

CanExecuteChanged CanExecuteChanged CanExecuteChanged 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.

(Inherited from RoutedCommand)

显式界面实现

ICommand.CanExecute(Object) ICommand.CanExecute(Object) ICommand.CanExecute(Object) ICommand.CanExecute(Object)

有关此成员的说明,请参阅CanExecute(Object)For a description of this members, see CanExecute(Object).

(Inherited from RoutedCommand)
ICommand.Execute(Object) ICommand.Execute(Object) ICommand.Execute(Object) ICommand.Execute(Object)

有关此成员的说明,请参阅Execute(Object)For a description of this members, see Execute(Object).

(Inherited from RoutedCommand)

适用于

另请参阅