Command 类

定义

定义一个包装 ActionICommand 实现。

public ref class Command : System::Windows::Input::ICommand
public class Command : System.Windows.Input.ICommand
type Command = class
    interface ICommand
Public Class Command
Implements ICommand
继承
Command
派生
实现

注解

以下示例创建一个新的 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)

初始化 Command 类的新实例。

Command(Action, Func<Boolean>)

初始化 Command 类的新实例。

Command(Action<Object>)

初始化 Command 类的新实例。

Command(Action<Object>, Func<Object,Boolean>)

初始化 Command 类的新实例。

方法

CanExecute(Object)

返回一个 Boolean,指示是否能使用给定的参数执行命令。

ChangeCanExecute()

发送 CanExecuteChanged

Execute(Object)

调用执行操作

事件

CanExecuteChanged

定义一个包装 ActionICommand 实现。

适用于