Class CommandBase
Base class for MCART implementations of the ICommand interface.
Implements
Inherited Members
Namespace: TheXDS.MCART.Types.Base
Assembly: MCART.Mvvm.dll
Syntax
public abstract class CommandBase : ICommand
Constructors
| Edit this page View SourceCommandBase(Action<object?>)
Base class for MCART implementations of the ICommand interface.
Declaration
protected CommandBase(Action<object?> action)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<object> | action | Action to associate with this command. |
Methods
| Edit this page View SourceCanExecute()
Determines whether the command can execute in its current state.
Declaration
public bool CanExecute()
Returns
| Type | Description |
|---|---|
| bool |
CanExecute(object?)
Determines whether the command can execute in its current state.
Declaration
public abstract 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()
Executes the action associated with this command.
Declaration
public void Execute()
Execute(object?)
Executes the action associated with this command.
Declaration
public virtual 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()
Raises the CanExecuteChanged event.
Declaration
protected void RaiseCanExecuteChanged()
TryExecute()
Checks whether the action can execute and, if so, executes it.
Declaration
public bool TryExecute()
Returns
| Type | Description |
|---|---|
| bool | true if the action was executed after checking; otherwise, false. |
TryExecute(object?)
Checks whether the action can execute and, if so, executes it.
Declaration
public bool TryExecute(object? arg)
Parameters
| Type | Name | Description |
|---|---|---|
| object | arg | Argument to use both for the check and for executing the action. |
Returns
| Type | Description |
|---|---|
| bool | true if the action was executed after checking; otherwise, false. |
Events
| Edit this page View SourceCanExecuteChanged
Raised when changes occur that affect whether the command should execute.
Declaration
public event EventHandler? CanExecuteChanged
Event Type
| Type | Description |
|---|---|
| EventHandler |