RoutedCommand RoutedCommand RoutedCommand RoutedCommand Class

定义

定义一个实现 ICommand 并在元素树之内进行路由的命令。Defines a command that implements ICommand and is routed through the element tree.

public ref 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")]
[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
type RoutedCommand = class
    interface ICommand
Public Class RoutedCommand
Implements ICommand
继承
RoutedCommandRoutedCommandRoutedCommandRoutedCommand
派生
属性
实现

注解

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

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"/><object property="predefinedCommandName"/>

-or-

<object property="predefinedClassName.predefinedCommandName"/><object property="predefinedClassName.predefinedCommandName"/>

-or-

<object property="{ customClassName.customCommandName}"/><object property="{ customClassName.customCommandName}"/>

XAML 值XAML Values

predefinedClassNamepredefinedClassName
预定义的命令类之一。One of the predefined command classes.

predefinedCommandNamepredefinedCommandName
预定义的命令之一。One of the predefined commands.

customClassNamecustomClassName
自定义类,该类包含自定义命令。A custom class which contains the custom command. 通常需要自定义类xlmns前缀映射; 请参阅XAML 命名空间和 WPF XAML 的 Namespace 映射Custom classes generally require an xlmns prefix mapping; see XAML Namespaces and Namespace Mapping for WPF XAML.

customCommandNamecustomCommandName
自定义命令。A custom command.

构造函数

RoutedCommand() RoutedCommand() RoutedCommand() RoutedCommand()

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

RoutedCommand(String, Type) RoutedCommand(String, Type) RoutedCommand(String, Type) RoutedCommand(String, Type)

使用指定的名称和所有者类型初始化 RoutedCommand 类的新实例。Initializes a new instance of the RoutedCommand class with the specified name and owner type.

RoutedCommand(String, Type, InputGestureCollection) RoutedCommand(String, Type, InputGestureCollection) RoutedCommand(String, Type, InputGestureCollection) RoutedCommand(String, Type, InputGestureCollection)

初始化的新实例RoutedCommand具有指定的名称、 所有者类型和笔势的集合类。Initializes a new instance of the RoutedCommand class with the specified name, owner type, and collection of gestures.

属性

InputGestures InputGestures InputGestures InputGestures

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

Name Name Name Name

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

OwnerType OwnerType OwnerType OwnerType

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

方法

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

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

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.

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.

显式界面实现

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

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

ICommand.Execute(Object) ICommand.Execute(Object) ICommand.Execute(Object) ICommand.Execute(Object)

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

适用于

另请参阅