Class RelayCommand
Describes a standard RelayCommand implementation commonly used under the MVVM pattern in WPF.
Implements
Inherited Members
Namespace: TheXDS.MCART.Component
Assembly: MCART.Wpf.Mvvm.dll
Syntax
public class RelayCommand : ICommand
Constructors
| Edit this page View SourceRelayCommand(Action<object?>)
Initializes a new instance of the RelayCommand class.
Declaration
public RelayCommand(Action<object?> action)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<object> | action | Command to execute. |
RelayCommand(Action<object?>, Func<object?, bool>?)
Describes a standard RelayCommand implementation commonly used under the MVVM pattern in WPF.
Declaration
public RelayCommand(Action<object?> action, Func<object?, bool>? canExecute)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<object> | action | Command to execute. |
| Func<object, bool> | canExecute | Function that determines whether the command can be executed. |
Methods
| Edit this page View SourceCanExecute(object?)
Defines the method that determines whether the command can execute in its current state.
Declaration
public bool CanExecute(object? parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| object | parameter | Data used by the command. If the command does not require data, this object can be set to null. |
Returns
| Type | Description |
|---|---|
| bool |
Execute(object?)
Defines the method to call when the command is invoked.
Declaration
public void Execute(object? parameter)
Parameters
| Type | Name | Description |
|---|---|---|
| object | parameter | Data used by the command. If the command does not require data, this object can be set to null. |
RaiseCanExecuteChanged()
Forces the command to re-evaluate CanExecute(object?).
Declaration
public static void RaiseCanExecuteChanged()
Events
| Edit this page View SourceCanExecuteChanged
Occurs when changes affect whether the command should execute.
Declaration
public event EventHandler? CanExecuteChanged
Event Type
| Type | Description |
|---|---|
| EventHandler |