Command 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义一个包装 System.Action 的 System.Windows.Input.ICommand 实现。
public class Command : System.Windows.Input.ICommand
	type Command = class
    interface ICommand
		- 继承
 - 
				System.ObjectCommand
 
- 派生
 
- 实现
 - 
		System.Windows.Input.ICommand
 
注解
以下示例创建一个新的 Command 并将其设置为按钮。
var command = new Command (() => Debug.WriteLine ("Command executed"));
var button = new Button {
  Text = "Hit me to execute the command",
  Command = command,
};
 更有用的方案采用 参数
var command = new Command (o => Debug.WriteLine ("Command executed: {0}", o));
var button = new Button {
  Text = "Hit me to execute the command",
  Command = command,
  CommandParameter = "button0",
};
 构造函数
| Command(Action, Func<Boolean>) | 
		 初始化 Command 类的新实例。  | 
        	
| Command(Action) | 
		 初始化 Command 类的新实例。  | 
        	
| Command(Action<Object>, Func<Object,Boolean>) | 
		 初始化 Command 类的新实例。  | 
        	
| Command(Action<Object>) | 
		 初始化 Command 类的新实例。  | 
        	
方法
| CanExecute(Object) | 
		 返回一个 System.Boolean,指示是否能使用给定的参数执行命令。  | 
        	
| ChangeCanExecute() | 
		 发送 System.Windows.Input.ICommand.CanExecuteChanged  | 
        	
| Execute(Object) | 
		 调用执行操作  | 
        	
事件
| CanExecuteChanged | 
		 在命令的目标需重新评估是否可执行该命令时发生。  |