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="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, InputGestureCollection) |
使用指定的名称、所有者类型和手势集合初始化类的新实例 RoutedCommand 。 |
| RoutedCommand(String, Type) |
使用指定的名称和所有者类型初始化类的新实例 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)。 |