Class RelayCommand
A command whose sole purpose is to relay its functionality to other
objects by invoking delegates. The default return value for the Can
Inherited Members
Namespace: Unity.AppUI.MVVM
Assembly: Unity.AppUI.MVVM.dll
Syntax
public class RelayCommand : IRelayCommand, ICommand
Constructors
RelayCommand(Action?)
Initializes a new instance of the Relay
Declaration
public RelayCommand(Action? execute)
Parameters
Type | Name | Description |
---|---|---|
Action | execute | The action to execute. |
Exceptions
Type | Condition |
---|---|
Argument |
Thrown if the action is null. |
RelayCommand(Action, Func<bool>)
Initializes a new instance of the Relay
Declaration
public RelayCommand(Action execute, Func<bool> canExecute)
Parameters
Type | Name | Description |
---|---|---|
Action | execute | The action to execute. |
Func<bool> | canExecute | Predicate used to determine if the command can execute. |
Exceptions
Type | Condition |
---|---|
Argument |
Thrown if the action is null. |
Methods
CanExecute()
Initializes a new instance of the Relay
Declaration
public bool CanExecute()
Returns
CanExecute(object?)
Determines whether this Relay
Declaration
public bool CanExecute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | Data used by the command. |
Returns
Execute()
Defines the method to be called when the command is invoked.
Declaration
public void Execute()
Execute(object?)
Executes the Relay
Declaration
public void Execute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | Data used by the command. |
NotifyCanExecuteChanged()
Notifies that the Can
Declaration
public void NotifyCanExecuteChanged()
Events
CanExecuteChanged
Occurs when changes occur that affect whether or not the command should execute.
Declaration
public event EventHandler? CanExecuteChanged
Event Type
Type | Description |
---|---|
Event |