RelayCommand<T>

References
public class RelayCommand<T> : ICommand
Command to relay execution and execute state to delegates
T

Constructors

RelayCommand

#
public RelayCommand(Action<T> execute, Predicate<T> canExecute)
Initializes a new instance of the RelayCommand<T> class.
Remarks: This constructor allows you to specify whether the command can be executed. If the state of the canExecute delegate changes, you can call UpdateCanExecute() to tell the control that is bound to this command to call the delegate again.
execute (Action<T>)Delegate to execute the command.
canExecute (Predicate<T>)Delegate to determine the state of whether the command can be executed.

RelayCommand

#
public RelayCommand(Action<T> execute)
Initializes a new instance of the RelayCommand<T> class.
Remarks: The CanExecute(object) will always return true.
execute (Action<T>)Delegate to execute the command.

Methods

CanExecute

#
public bool CanExecute(object parameter)
Determines whether this command can execute with the specified parameter.
parameter (object)Command argument from the control.
true if this command can execute; otherwise, false.

Execute

#
public void Execute(object parameter)
Executes the command with the specified parameter.

OnCanExecuteChanged

#
protected virtual void OnCanExecuteChanged(EventArgs e)
Raises the CanExecuteChanged event.

UpdateCanExecute

#
public void UpdateCanExecute()
Tells consumers of this command that the CanExecute(object) state has changed and should be queried again.

Events

CanExecuteChanged

#
public event EventHandler CanExecuteChanged
Occurs when the return value of CanExecute(object) is changed.