ActionCommand.CanExecute C# (CSharp) Method

CanExecute() public method

Defines the method that determines whether the command can execute in its current state.
public CanExecute ( object parameter ) : bool
parameter object Data used by the command. /// If the command does not require data to be passed, /// this object can be set to null.
return bool
    public bool CanExecute(object parameter)
    {
        return (_executeAction != null && _canExecuteFunction != null && _canExecuteFunction());                    
    }

Usage Example

コード例 #1
0
		public void No_Execution() {
			var executed = false;
			var command = new ActionCommand(() => executed = true, () => false, false);

			var canExecute = command.CanExecute(null);
			Assert.IsFalse(canExecute);
			command.Execute(null);
			Assert.IsFalse(executed);

			var obj = new Object();
			canExecute = command.CanExecute(obj);
			Assert.IsFalse(canExecute);
			command.Execute(obj);
			Assert.IsFalse(executed);
		}
All Usage Examples Of ActionCommand::CanExecute