Class DelegateCommand<T>
Represents a command that can perform a given action.
Implements
Namespace: Syncfusion.UI.Xaml.Core
Assembly: Syncfusion.Core.WinUI.dll
Syntax
public class DelegateCommand<T> : Object, ICommand
Type Parameters
Name |
---|
T |
Constructors
DelegateCommand(Action<T>)
Initializes a new instance of the DelegateCommand class.
Declaration
public DelegateCommand(Action<T> method)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | method | The method. |
DelegateCommand(Action<T>, Predicate<T>)
Initializes a new instance of the DelegateCommand class.
Declaration
public DelegateCommand(Action<T> action, Predicate<T> canExecute)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T> | action | The action to execute when called. |
System.Predicate<T> | canExecute | The function to call to determine if the command can execute the action. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the execute action is null. |
Methods
CanExecute(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 |
---|---|---|
System.Object | parameter | Data used by the command. If the command does not require data to be passed, this object can be set to null. |
Returns
Type | Description |
---|---|
System.Boolean | Returns a value indicating whether this command can be executed. |
Execute(Object)
Defines the method to be called when the command is invoked.
Declaration
public void Execute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parameter | Data used by the command. If the command does not require data to be passed, this object can be set to null. |
RaiseCanExecuteChanged()
Raises CanExecuteChanged event to notify changes in command status.
Declaration
public void RaiseCanExecuteChanged()
Events
CanExecuteChanged
Occurs when changes occur that affect whether or not the command should execute.
Declaration
public event EventHandler CanExecuteChanged
Event Type
Type |
---|
System.EventHandler |