Show / Hide Table of Contents

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().

Inheritance
object
ExceptionHandlingRelayCommand
Implements
IRelayCommand
ICommand
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.Presentation
Assembly: Benday.Presentation.dll
Syntax
public class ExceptionHandlingRelayCommand : IRelayCommand, ICommand

Constructors

| Edit this page View Source

ExceptionHandlingRelayCommand(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 Source

CanExecute(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.

| Edit this page View Source

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
| Edit this page View Source

NotifyCanExecuteChanged()

Notifies that the CanExecute(object) property has changed.

Declaration
public void NotifyCanExecuteChanged()

Events

| Edit this page View Source

CanExecuteChanged

Occurs when changes occur that affect whether or not the command should execute.

Declaration
public event EventHandler? CanExecuteChanged
Event Type
Type Description
EventHandler

Implements

IRelayCommand
ICommand
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com