Command クラス

定義

Action をラップする ICommand 実装を定義します。

public class Command : System.Windows.Input.ICommand
type Command = class
    interface 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(Action, Func<Boolean>)

コマンド クラスの新しいインスタンスを初期化します。

Command(Action<Object>)

コマンド クラスの新しいインスタンスを初期化します。

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

コマンド クラスの新しいインスタンスを初期化します。

メソッド

CanExecute(Object)

指定したパラメータをーを使用して、コマンドが実行できるかどうかを示す Boolean を返します。

ChangeCanExecute()

CanExecuteChanged を送信します。

Execute(Object)

アクションの実行を呼び出します

イベント

CanExecuteChanged

コマンドが実行できるかどうかを、コマンドの対象が再評価する必要がある場合に発生します。

適用対象