Edit

Share via


RelayCommand<T> Class

Definition

A generic command whose sole purpose is to relay its functionality to other objects by invoking delegates. The default return value for the CanExecute method is true. This class allows you to accept command parameters in the Execute(T) and CanExecute(T) callback methods.

public sealed class RelayCommand<T> : CommunityToolkit.Mvvm.Input.IRelayCommand<T>, System.Windows.Input.ICommand
type RelayCommand<'T> = class
    interface IRelayCommand<'T>
    interface IRelayCommand
    interface ICommand
Public NotInheritable Class RelayCommand(Of T)
Implements ICommand, IRelayCommand(Of T)

Type Parameters

T

The type of parameter being passed as input to the callbacks.

Inheritance
RelayCommand<T>
Implements

Constructors

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.

Methods

CanExecute(Object)

Determines whether the command can execute in its current state.

CanExecute(T)

Provides a strongly-typed variant of CanExecute(Object).

Execute(Object)

Defines the method to be called when the command is invoked.

Execute(T)

Provides a strongly-typed variant of Execute(Object).

NotifyCanExecuteChanged()

Notifies that the CanExecute(Object) property has changed.

Events

CanExecuteChanged

Occurs when changes take place that affect whether or not the command should execute.

Applies to