C# Class NotifyMessageDemo.DelegateCommand

A command that executes delegates to determine whether the command can execute, and to execute the command.

This command implementation is useful when the command simply needs to execute a method on a view model. The delegate for determining whether the command can execute is optional. If it is not provided, the command is considered always eligible to execute.

Inheritance: ICommand
显示文件 Open project: acid2000/OfficeCheevos

Public Methods

Method Description
CanExecute ( object parameter ) : bool

Determines whether this command can execute.

If there is no delegate to determine whether the command can execute, this method will return . If a delegate was provided, this method will invoke that delegate.

DelegateCommand ( Action execute ) : System

Constructs an instance of DelegateCommand.

This constructor creates the command without a delegate for determining whether the command can execute. Therefore, the command will always be eligible for execution.

DelegateCommand ( Action execute, Predicate canExecute ) : System

Constructs an instance of DelegateCommand.

Execute ( object parameter ) : void

Executes this command.

This method invokes the provided delegate to execute the command.

Method Details

CanExecute() public method

Determines whether this command can execute.
If there is no delegate to determine whether the command can execute, this method will return . If a delegate was provided, this method will invoke that delegate.
public CanExecute ( object parameter ) : bool
parameter object /// The command parameter. ///
return bool

DelegateCommand() public method

Constructs an instance of DelegateCommand.
This constructor creates the command without a delegate for determining whether the command can execute. Therefore, the command will always be eligible for execution.
public DelegateCommand ( Action execute ) : System
execute Action /// The delegate to invoke when the command is executed. ///
return System

DelegateCommand() public method

Constructs an instance of DelegateCommand.
public DelegateCommand ( Action execute, Predicate canExecute ) : System
execute Action /// The delegate to invoke when the command is executed. ///
canExecute Predicate /// The delegate to invoke to determine whether the command can execute. ///
return System

Execute() public method

Executes this command.
This method invokes the provided delegate to execute the command.
public Execute ( object parameter ) : void
parameter object /// The command parameter. ///
return void