Class RelayCommand<T>
Implementation of IRelayCommand that allows for CommandParameter to be passed in.
Inherited Members
Namespace: Unity.AppUI.MVVM
Syntax
public class RelayCommand<T> : IRelayCommand<T>, IRelayCommand, ICommand
Type Parameters
Name | Description |
---|---|
T | The type of the CommandParameter. |
Constructors
RelayCommand(Action<T>)
Initializes a new instance of the RelayCommand<T> class.
Declaration
public RelayCommand(Action<T> execute)
Parameters
Type | Name | Description |
---|---|---|
Action<T> | execute | The action to execute. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the action is null. |
RelayCommand(Action<T>, Predicate<T>)
Initializes a new instance of the RelayCommand<T> class.
Declaration
public RelayCommand(Action<T> execute, Predicate<T> canExecute)
Parameters
Type | Name | Description |
---|---|---|
Action<T> | execute | The action to execute. |
Predicate<T> | canExecute | The predicate executed to determine if the command can execute. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the action or the predicate is null. |
Methods
CanExecute(T)
Determines whether this RelayCommand<T> can execute in its current state.
Declaration
public bool CanExecute(T parameter)
Parameters
Type | Name | Description |
---|---|---|
T | parameter | Data used by the command. |
Returns
Type | Description |
---|---|
Boolean |
Implements
CanExecute(Object)
Determines whether this RelayCommand<T> can execute in its current state.
Declaration
public bool CanExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
Object | parameter | Data used by the command. |
Returns
Type | Description |
---|---|
Boolean |
Implements
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
Execute(T)
Executes the RelayCommand<T> on the current command target.
Declaration
public void Execute(T parameter)
Parameters
Type | Name | Description |
---|---|---|
T | parameter | Data used by the command. |
Implements
Execute(Object)
Executes the RelayCommand<T> on the current command target.
Declaration
public void Execute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
Object | parameter | Data used by the command. |
Implements
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the |
NotifyCanExecuteChanged()
Notifies that the CanExecuteChanged property has changed.
Declaration
public void NotifyCanExecuteChanged()
Implements
Events
CanExecuteChanged
Event raised when CanExecute(Object) changes.
Declaration
public event EventHandler CanExecuteChanged
Event Type
Type | Description |
---|---|
EventHandler |