RoutedCommand 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义一个实现 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上的RoutedCommand和CanExecute方法不包含命令的应用程序逻辑,与典型的ICommand情况一样,但是,这些方法会引发遍历元素树以查找具有 a CommandBinding对象的事件。 附加到包含命令逻辑的 CommandBinding 事件处理程序。
该方法 Execute 引发 PreviewExecuted 和 Executed 事件。 该方法 CanExecute 引发 PreviewCanExecute 和 CanExecute 事件。
XAML 属性用法
<object property="predefinedCommandName"/>
- 或 -
<object property="predefinedClassName.predefinedCommandName"/>
- 或 -
<object property="{ customClassName.customCommandName}"/>
XAML 值
predefinedClassName
预定义命令类之一。
predefinedCommandName
预定义命令之一。
customClassName
包含自定义命令的自定义类。 自定义类通常需要 xlmns
前缀映射;请参阅 WPF XAML 的 XAML 命名空间和命名空间映射。
customCommandName
自定义命令。
构造函数
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)。 |