Show / Hide Table of Contents

Class DelegateCommandBase

Inheritance
System.Object
DelegateCommandBase
DelegateCommand
DelegateCommand<T>
Implements
System.Windows.Input.ICommand
IActiveAware
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.Presentation.Commands
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public abstract class DelegateCommandBase : ICommand, IActiveAware

Constructors

View Source

DelegateCommandBase(Action<Object>, Func<Object, Boolean>)

Create a new instance of a DelegateCommandBase, specifying both the execute action and the can execute function.

Declaration
protected DelegateCommandBase(Action<object> executeMethod, Func<object, bool> canExecuteMethod)
Parameters
Type Name Description
System.Action<System.Object> executeMethod

The System.Action to execute when System.Windows.Input.ICommand.Execute(System.Object) is invoked.

System.Func<System.Object, System.Boolean> canExecuteMethod

The System.Func<T, TResult> to invoked when System.Windows.Input.ICommand.CanExecute(System.Object) is invoked.

Properties

View Source

IsActive

Gets or sets a value indicating whether the object is active.

Declaration
public bool IsActive { get; set; }
Property Value
Type Description
System.Boolean

true if the object is active; otherwise false.

Methods

View Source

CanExecute(Object)

Determines if the command can execute with the provided parameter by invoking the System.Func<T, TResult> supplied during construction.

Declaration
protected bool CanExecute(object parameter)
Parameters
Type Name Description
System.Object parameter

The parameter to use when determining if this command can execute.

Returns
Type Description
System.Boolean

Returns true if the command can execute. langword_csharp_False otherwise.

View Source

Execute(Object)

Executes the command with the provided parameter by invoking the System.Action<T> supplied during construction.

Declaration
protected void Execute(object parameter)
Parameters
Type Name Description
System.Object parameter
View Source

OnCanExecuteChanged()

Raises System.Windows.Input.ICommand.CanExecuteChanged on the UI thread so every command invoker can re-query System.Windows.Input.ICommand.CanExecute(System.Object) to check if the command can execute.

Declaration
protected virtual void OnCanExecuteChanged()
View Source

OnIsActiveChanged()

This raises the IsActiveChanged event.

Declaration
protected virtual void OnIsActiveChanged()
View Source

RaiseCanExecuteChanged()

Raises CanExecuteChanged on the UI thread so every command invoker can query to check if the command can execute. Note that this will trigger the execution of CanExecute(Object) once for each invoker.

Declaration
public void RaiseCanExecuteChanged()

Events

View Source

CanExecuteChanged

Occurs when changes occur that affect whether or not the command should execute. You must keep a hard reference to the handler to avoid garbage collection and unexpected results. See remarks for more information.

Declaration
public event EventHandler CanExecuteChanged
Event Type
Type Description
System.EventHandler
Remarks

When subscribing to the System.Windows.Input.ICommand.CanExecuteChanged event using code (not when binding using XAML) will need to keep a hard reference to the event handler. This is to prevent garbage collection of the event handler because the command implements the Weak Event pattern so it does not have a hard reference to this handler. An example implementation can be seen in the CompositeCommand and CommandBehaviorBase classes. In most scenarios, there is no reason to sign up to the CanExecuteChanged event directly, but if you do, you are responsible for maintaining the reference.

Examples

The following code holds a reference to the event handler. The myEventHandlerReference value should be stored in an instance member to avoid it from being garbage collected.

EventHandler myEventHandlerReference = new EventHandler(this.OnCanExecuteChanged);
command.CanExecuteChanged += myEventHandlerReference;
View Source

IsActiveChanged

Fired if the IsActive property changes.

Declaration
public virtual event EventHandler IsActiveChanged
Event Type
Type Description
System.EventHandler

Explicit Interface Implementations

View Source

ICommand.CanExecute(Object)

Declaration
bool ICommand.CanExecute(object parameter)
Parameters
Type Name Description
System.Object parameter
Returns
Type Description
System.Boolean
View Source

ICommand.Execute(Object)

Declaration
void ICommand.Execute(object parameter)
Parameters
Type Name Description
System.Object parameter

Implements

System.Windows.Input.ICommand
IActiveAware

Extension Methods

CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
SerializableObjectCloneExtension.Clone<T>(T)
  • View Source
Back to top Generated by DocFX