Command Classe

Définition

Définit une implémentation System.Windows.Input.ICommand qui wrappe un System.Action.

public class Command : System.Windows.Input.ICommand
type Command = class
    interface ICommand
Héritage
System.Object
Command
Dérivé
Implémente
System.Windows.Input.ICommand

Remarques

L’exemple suivant crée une nouvelle commande et définissez-la sur un bouton.

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

Les scénarios plus utiles prennent un paramètre

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

Constructeurs

Command(Action)

Initialise une nouvelle instance de la classe Command.

Command(Action, Func<Boolean>)

Initialise une nouvelle instance de la classe Command.

Command(Action<Object>)

Initialise une nouvelle instance de la classe Command.

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

Initialise une nouvelle instance de la classe Command.

Méthodes

CanExecute(Object)

Retourne un System.Boolean indiquant si la commande peut être exécutée avec le paramètre donné.

ChangeCanExecute()

Envoie un System.Windows.Input.ICommand.CanExecuteChanged.

Execute(Object)

Appelle l’action d’exécution.

Événements

CanExecuteChanged

Se produit quand la cible de la commande doit redéterminer si la commande peut être exécutée ou non.

S’applique à