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>)
- Source:
- RelayCommand%7BT%7D.cs
- Source:
- RelayCommand%7BT%7D.cs
Initializes a new instance of the RelayCommand<T> class that can always execute.
public RelayCommand(Action<T?> execute);
new CommunityToolkit.Mvvm.Input.RelayCommand<'T> : Action<'T> -> CommunityToolkit.Mvvm.Input.RelayCommand<'T>
Public Sub New (execute As Action(Of T))
Parameters
- execute
- Action<T>
The execution logic.
Exceptions
Thrown if execute
is null
.
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>)
- Source:
- RelayCommand%7BT%7D.cs
- Source:
- RelayCommand%7BT%7D.cs
Initializes a new instance of the RelayCommand<T> class.
public RelayCommand(Action<T?> execute, Predicate<T?> canExecute);
new CommunityToolkit.Mvvm.Input.RelayCommand<'T> : Action<'T> * Predicate<'T> -> CommunityToolkit.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.
Exceptions
Thrown if execute
or canExecute
are null
.
Remarks
See notes in RelayCommand<T>(Action<T>).