RelayCommand<T> Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
RelayCommand<T>(Action<T>) |
Initializes a new instance of the RelayCommand<T> class that can always execute. |
RelayCommand<T>(Action<T>, Predicate<T>) |
Initializes a new instance of the RelayCommand<T> class. |
RelayCommand<T>(Action<T>)
Initializes a new instance of the RelayCommand<T> class that can always execute.
public RelayCommand (Action<T?> execute);
new Microsoft.Toolkit.Mvvm.Input.RelayCommand<'T> : Action<'T> -> Microsoft.Toolkit.Mvvm.Input.RelayCommand<'T>
Public Sub New (execute As Action(Of T))
Parameters
- execute
- Action<T>
The execution logic.
Remarks
Due to the fact that the ICommand interface exposes methods that accept a nullable Object parameter, it is recommended that if T
is a reference type, you should always declare it as nullable, and to always perform checks within execute
.
Applies to
RelayCommand<T>(Action<T>, Predicate<T>)
Initializes a new instance of the RelayCommand<T> class.
public RelayCommand (Action<T?> execute, Predicate<T?> canExecute);
new Microsoft.Toolkit.Mvvm.Input.RelayCommand<'T> : Action<'T> * Predicate<'T> -> Microsoft.Toolkit.Mvvm.Input.RelayCommand<'T>
Public Sub New (execute As Action(Of T), canExecute As Predicate(Of T))
Parameters
- execute
- Action<T>
The execution logic.
- canExecute
- Predicate<T>
The execution status logic.
Remarks
See notes in RelayCommand<T>(Action<T>).