Class ExceptionHandlingRelayCommand
A relay command that handles exceptions by showing them to the user. This class wraps an existing action and executes it when the command is invoked. If the action throws an exception, the exception is caught and is shown via IMessageManager.ShowMessage().
Inherited Members
Namespace: Benday.Presentation
Assembly: Benday.Presentation.dll
Syntax
public class ExceptionHandlingRelayCommand : IRelayCommand, ICommand
Constructors
| Edit this page View SourceExceptionHandlingRelayCommand(IMessageManager, Action)
Creates a new instance of the ExceptionHandlingRelayCommand class.
Declaration
public ExceptionHandlingRelayCommand(IMessageManager msgManager, Action execute)
Parameters
Type | Name | Description |
---|---|---|
IMessageManager | msgManager | Instance of IMessageManager to use |
Action | execute | The action to perform |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
Methods
| Edit this page View SourceCanExecute(object?)
Returns true if the command can be executed.
Declaration
public bool CanExecute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter |
Returns
Type | Description |
---|---|
bool | This class always returns true. |
Execute(object?)
Executes the action and handles any exceptions by showing them to the user.
Declaration
public void Execute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter |
NotifyCanExecuteChanged()
Notifies that the CanExecute(object) property has changed.
Declaration
public void NotifyCanExecuteChanged()
Events
| Edit this page View SourceCanExecuteChanged
Occurs when changes occur that affect whether or not the command should execute.
Declaration
public event EventHandler? CanExecuteChanged
Event Type
Type | Description |
---|---|
EventHandler |