Class RelayCommand
- Namespace
- EasySoftware.MvvmMini
- Assembly
- EasySoftware.MvvmMini.dll
An asynchronous command without a parameter.
public class RelayCommand : RelayCommandBase, IRelayCommand, ICommand
- Inheritance
-
RelayCommand
- Implements
- Inherited Members
Constructors
RelayCommand(Func<Task>)
Initializes a command that can always execute.
public RelayCommand(Func<Task> execute)
Parameters
Exceptions
- ArgumentNullException
executeis null.
RelayCommand(Func<Task>, Func<bool>)
Initializes a command whose availability is re-evaluated through CommandManager.
public RelayCommand(Func<Task> execute, Func<bool> canExecute)
Parameters
executeFunc<Task>The work to run when the command executes.
canExecuteFunc<bool>Returns whether the command can execute.
Exceptions
- ArgumentNullException
executeis null.
RelayCommand(Func<Task>, Func<bool>, bool)
Initializes a command.
public RelayCommand(Func<Task> execute, Func<bool> canExecute, bool useCommandManager)
Parameters
executeFunc<Task>The work to run when the command executes.
canExecuteFunc<bool>Returns whether the command can execute, or null if it always can.
useCommandManagerbooltrue to re-evaluate CanExecute(object) through CommandManager; false to re-evaluate it only when RaiseCanExecuteChanged() is called.
Exceptions
- ArgumentNullException
executeis null.
Methods
CanExecute(object)
Determines whether the command can execute in its current state.
public override bool CanExecute(object parameter)
Parameters
parameterobjectThe command parameter.
Returns
Execute(object)
Executes the command without waiting for it to finish. Use ExecuteAsync(object) to await it.
public override void Execute(object parameter)
Parameters
parameterobjectThe command parameter.
ExecuteAsync(object)
Executes the command and returns a task that completes when the work is done.
public override Task ExecuteAsync(object parameter)
Parameters
parameterobjectThe command parameter.
Returns
- Task
A task that represents the execution.