DelegateCommand<T> Class
Provides an System.Windows.Input.ICommand implementation based on delegates.
public class DelegateCommand<T> : ICommand
- Type Parameters:
-
T
-The parameter type.
- Inheritance:
- System.Object Object
- Derived:
- PreviewableDelegateCommand<T>
Constructors
DelegateCommand(Action<T>)
Initializes an instance of the DelegateCommand
class.
public DelegateCommand(Action<T> executeAction)
Parameter | Type | Description |
---|---|---|
executeAction | System.Action<T> | The execute action. |
DelegateCommand(Action<T>, Func<T, Boolean>)
Initializes an instance of the DelegateCommand
class.
public DelegateCommand(Action<T> executeAction, Func<T, bool> canExecuteFunc)
Parameter | Type | Description |
---|---|---|
executeAction | System.Action<T> | The execute action. |
canExecuteFunc | System.Func<T, System.Boolean> | 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
- System.Boolean:
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
Occurs after the can-execute state has changed.
public event EventHandler CanExecuteChanged
Event Type
- System.EventHandler
Inherited Members
- System.Object.ToString()
- System.Object.Equals(System.Object)
- System.Object.Equals(System.Object, System.Object)
- System.Object.ReferenceEquals(System.Object, System.Object)
- System.Object.GetHashCode()
- System.Object.GetType()
- System.Object.MemberwiseClone()