MVVMbasics Logo

mobilemotion.eu Logo


Back to Class Reference home page


MVVMbasics.Attributes
Class BaseCommand

System.Windows.Input.ICommand
  extended by MVVMbasics.Commands.BaseCommand
 

 
public class BaseCommand : ICommand

Simple delegate command all actual commands can be derived from. Works with and without parameters.


Constructor Summary
public  BaseCommand(Action execute)
Constructor that creates a Command and registers a parameterless method to it.
public  BaseCommand(Action execute, Expression<Func<bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)
Constructor that creates a Command with a CanExecute condition and registers a parameterless method to it.
public  BaseCommand(Action execute, Func<bool> canExecute)
Constructor that creates a Command with a CanExecute condition and registers a parameterless method to it.
Deprecated. Use Constructor BaseCommand(Action execute, Expression<Func<bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties) or Model's method CreateCommand(Action execute, Expression<Func<bool>> canExecute, params Expression<Func<object&glt;>[] dependsOnProperties) instead.
public  BaseCommand(Action<object> execute)
Constructor that creates a Command and registers a method with one parameter of type object to it.
public  BaseCommand(Action<object> execute, Expression<Func<object, bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)
Constructor that creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.
public  BaseCommand(Action<object> execute, Predicate<object> canExecute)
Constructor that creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.
Deprecated. Use Constructor BaseCommand(Action execute, Expression<Func<object, bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties) or Model's method CreateCommand(Action execute, Expression<Func<object, bool>> canExecute, params Expression<Func<object>>[] dependsOnProperties) instead.
public  BaseCommand(Func<Task> execute)
Constructor that creates a Command and registers a parameterless method to it.
public  BaseCommand(Func<Task> execute, Expression<Func<bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)
Constructor that creates a Command with a CanExecute condition and registers a parameterless method to it.
public  BaseCommand(Func<object, Task> execute)
Constructor that creates a Command and registers a method with one parameter of type object to it.
public  BaseCommand(Func<object, Task> execute, Expression<Func<object, bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)
Constructor that creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.
 
Event Summary
public event EventHandler  CanExecuteChanged
Event indicating that the CanExecute condition might have changed and must be re-evaluated.
 
Method Summary
void  NotifyCanExecuteChanged()
Fires the CanExecuteChanged event, forcing the CanExecute condition to be re-evaluated.
bool  CanExecute()
Evaluates the CanExecute condition.
bool  CanExecute(object parameter)
Evaluates the CanExecute condition.
void  Execute()
Calls the method that is registered to this Command.
async void  Execute(object parameter)
Calls the method that is registered to this Command.
Task Execute(object parameter)
Calls the asynchronous method that is registered to this Command.
 
Constructor Detail

BaseCommand

public BaseCommand(Action execute)

Constructor that creates a Command and registers a parameterless method to it.

Parameters:

execute - Parameterless method.


BaseCommand

public BaseCommand(Action execute, Expression<Func<bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)

Constructor that creates a Command with a CanExecute condition and registers a parameterless method to it.

Parameters:

execute - Parameterless method.
canExecute - Condition that defines whether this Command is enabled or not.
owner - Model or Viewmodel that hosts this Command (and all Properties it depends on).
dependsOnProperties - List of Properties this Command depends on.


BaseCommand

public BaseCommand(Action execute, Func<bool> canExecute)

Constructor that creates a Command with a CanExecute condition and registers a parameterless method to it.

Deprecated. Use Constructor BaseCommand(Action execute, Expression<Func<bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties) or Model's method CreateCommand(Action execute, Expression<Func<bool>> canExecute, params Expression<Func<object&glt;>[] dependsOnProperties) instead.

Parameters:

execute - Parameterless method.
canExecute - Condition that defines whether this Command is enabled or not.


BaseCommand

public BaseCommand(Action<object> execute)

Constructor that creates a Command and registers a method with one parameter of type object to it.

Parameters:

execute - Method with one parameter of type object.


BaseCommand

public BaseCommand(Action<object> execute, Expression<Func<object, bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)

Constructor that creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.

Parameters:

execute - Method with one parameter of type object.
canExecute - Condition that defines whether this Command is enabled or not.
owner - Model or Viewmodel that hosts this Command (and all Properties it depends on).
dependsOnProperties - List of Properties this Command depends on.


BaseCommand

public BaseCommand(Action<object> execute, Predicate<object> canExecute)

Constructor that creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.

Deprecated. Use Constructor BaseCommand(Action execute, Expression<Func<object, bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties) or Model's method CreateCommand(Action execute, Expression<Func<object, bool>> canExecute, params Expression<Func<object>>[] dependsOnProperties) instead.

Parameters:

execute - Method with one parameter of type object.
canExecute - Condition that defines whether this Command is enabled or not.


BaseCommand

public BaseCommand(Func<Task> execute)

Constructor that creates a Command and registers a parameterless method to it.

Parameters:

execute - Parameterless method.


BaseCommand

public BaseCommand(Func<Task> execute, Expression<Func<bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)

Constructor that creates a Command with a CanExecute condition and registers a parameterless method to it.

Parameters:

execute - Parameterless method.
canExecute - Condition that defines whether this Command is enabled or not.
owner - Model or Viewmodel that hosts this Command (and all Properties it depends on).
dependsOnProperties - List of Properties this Command depends on.


BaseCommand

public BaseCommand(Func<object, Task> execute)

Constructor that creates a Command and registers a method with one parameter of type object to it.

Parameters:

execute - Method with one parameter of type object.


BaseCommand

public BaseCommand(Func<object, Task> execute, Expression<Func<object, bool>> canExecute, INotifyPropertyChanged owner, params Expression<Func<object>>[] dependsOnProperties)

Constructor that creates a Command with a CanExecute condition and registers a method with one parameter of type object to it.

Parameters:

execute - Method with one parameter of type object.
canExecute - Condition that defines whether this Command is enabled or not.
owner - Model or Viewmodel that hosts this Command (and all Properties it depends on).
dependsOnProperties - List of Properties this Command depends on.

Method Detail

NotifyCanExecuteChanged

public void NotifyCanExecuteChanged()

Fires the CanExecuteChanged event, forcing the CanExecute condition to be re-evaluated.


CanExecute

public bool CanExecute()

Evaluates the CanExecute condition.

Returns:

TRUE if the Command shall be enabled, FALSE otherwise.


CanExecute

public bool CanExecute(object parameter)

Evaluates the CanExecute condition.

Parameters:

parameter - Parameter to be passed to the CanExecute condition.

Returns:

TRUE if the Command shall be enabled, FALSE otherwise.


Execute

public void Execute()

Calls the method that is registered to this Command.


Execute

public async void Execute(object parameter)

Calls the method that is registered to this Command.

Parameters:

parameter - Parameter to be passed to the CanExecute condition.


Execute

public Task Execute(object parameter)

Calls the asynchronous method that is registered to this Command.

Parameters:

parameter - Parameter to be passed to the CanExecute condition.

Returns:

Task representing the asynchronous operation.