DelegateCommand<T> Class
Provides an ICommand implementation based on delegates.
public class DelegateCommand<T>
- Type Parameters:
-
T
-The parameter type.
- Inheritance:
- object object
- Derived:
- PreviewableDelegateCommand<T>
Constructors
DelegateCommand(Action<T?>)
Initializes an instance of the class.
public DelegateCommand(Action<T?> executeAction)
Parameter | Type | Description |
---|---|---|
executeAction | Action<T> | The execute action. |
DelegateCommand(Action<T?>, Func<T?, bool>?)
Initializes an instance of the class.
public DelegateCommand(Action<T?> executeAction, Func<T?, bool>? canExecuteFunc)
Parameter | Type | Description |
---|---|---|
executeAction | Action<T> | The execute action. |
canExecuteFunc | Func<T, bool> | The can-execute function. |
Methods
CanExecute(T?)
Returns whether the command can execute.
public bool CanExecute(T? parameter)
Parameter | Type | Description |
---|---|---|
parameter | T | The parameter to examine. |
Returns
- bool:
true
if the command can execute; otherwise,false
.
Execute(T?)
Executes the command.
public void Execute(T? parameter)
Parameter | Type | Description |
---|---|---|
parameter | T | The parameter to examine. |
RaiseCanExecuteChanged()
Raises the CanExecuteChanged event.
public void RaiseCanExecuteChanged()
Events
CanExecuteChanged
Raised after the can-execute state has changed.
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()