Udostępnij za pośrednictwem


Command Klasa

Definicja

Definiuje implementację ICommand , która opakowuje Actionelement .

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
Dziedziczenie
Command
Pochodne
Implementuje

Uwagi

Poniższy przykład tworzy nowe polecenie i ustawia go na przycisk.

var command = new Command (() => Debug.WriteLine ("Command executed"));
var button = new Button {
  Text = "Hit me to execute the command",
  Command = command,
};

Bardziej przydatne scenariusze przyjmuje parametr

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",
};

Konstruktory

Command(Action)

Inicjuje nowe wystąpienie klasy Command.

Command(Action, Func<Boolean>)

Inicjuje nowe wystąpienie klasy Command.

Command(Action<Object>)

Inicjuje nowe wystąpienie klasy Command.

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

Inicjuje nowe wystąpienie klasy Command.

Metody

CanExecute(Object)

Zwraca wartość wskazującą Boolean , czy polecenie może być exectued z danym parametrem.

ChangeCanExecute()

Wyślij CanExecuteChanged

Execute(Object)

Wywołuje akcję wykonania

Zdarzenia

CanExecuteChanged

Definiuje implementację ICommand , która opakowuje Actionelement .

Dotyczy