Sdílet prostřednictvím


Command Třída

Definice

Definuje implementaciICommand, která zabalí objekt .Action

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
Dědičnost
Command
Odvozené
Implementuje

Poznámky

Následující příklad vytvoří nový příkaz a nastaví ho na tlačítko.

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

Užitečnější scénáře s parametrem

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, Func<Boolean>)

Inicializuje novou instanci Třídy Command.

Command(Action)

Inicializuje novou instanci Třídy Command.

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

Inicializuje novou instanci Třídy Command.

Command(Action<Object>)

Inicializuje novou instanci Třídy Command.

Metody

CanExecute(Object)

Vrátí hodnotu označující Boolean , zda lze příkaz exectued s daným parametrem.

ChangeCanExecute()

Odeslat CanExecuteChanged

Execute(Object)

Vyvolá akci spuštění.

Událost

CanExecuteChanged

Definuje implementaciICommand, která zabalí objekt .Action

Platí pro