Back to Class Reference home page
System.Windows.Input.ICommand
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 |
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 |
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 |
---|
public BaseCommand(Action execute)
Constructor that creates a Command and registers a parameterless method to it.
execute
- Parameterless method.
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.
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.
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.
execute
- Parameterless method.
canExecute
- Condition that defines whether this Command is enabled or not.
public BaseCommand(Action<object> execute)
Constructor that creates a Command and registers a method with one parameter of type object
to it.
execute
- Method with one parameter of type object
.
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.
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.
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.
execute
- Method with one parameter of type object
.
canExecute
- Condition that defines whether this Command is enabled or not.
public BaseCommand(Func<Task> execute)
Constructor that creates a Command and registers a parameterless method to it.
execute
- Parameterless method.
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.
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.
public BaseCommand(Func<object, Task> execute)
Constructor that creates a Command and registers a method with one parameter of type object
to it.
execute
- Method with one parameter of type object
.
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.
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 |
---|
public void NotifyCanExecuteChanged()
Fires the CanExecuteChanged
event, forcing the CanExecute
condition to be re-evaluated.
public bool CanExecute()
Evaluates the CanExecute
condition.
TRUE if the Command shall be enabled, FALSE otherwise.
public bool CanExecute(object parameter)
Evaluates the CanExecute
condition.
parameter
- Parameter to be passed to the CanExecute
condition.
TRUE if the Command shall be enabled, FALSE otherwise.
public void Execute()
Calls the method that is registered to this Command.
public async void Execute(object parameter)
Calls the method that is registered to this Command.
parameter
- Parameter to be passed to the CanExecute
condition.
public Task Execute(object parameter)
Calls the asynchronous method that is registered to this Command.
parameter
- Parameter to be passed to the CanExecute
condition.
Task representing the asynchronous operation.