RelayCommand<T> Constructors

Definition

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>).

Applies to