Table of Contents

Class ShellCommand

Namespace
The.WPF.Shell
Assembly
Instagile.WPF.dll

See also AsyncShellCommand if you need an asynchronous shell command.

public class ShellCommand : ICommand
Inheritance
ShellCommand
Implements
Derived
Inherited Members

Constructors

ShellCommand(ISurface, Action, Func<bool>, Action<EventHandler>)

public ShellCommand(ISurface surface, Action execute, Func<bool> canExecute = null, Action<EventHandler> subscribe = null)

Parameters

surface ISurface

UI element which should handle errors.

execute Action

Action to run when command is invoked.

canExecute Func<bool>

Optional. Synchronous enablement test.

subscribe Action<EventHandler>

Optional. An Action<T> to use to subscribe to an event. The subscription will be stored in case the event uses the weak event pattern. When the event is raised, CanExecuteChanged will be raised. If null, no subscription will take place.

ShellCommand(ISurface, Action<object>, Func<object, bool>, Action<EventHandler>)

public ShellCommand(ISurface surface, Action<object> execute, Func<object, bool> canExecute = null, Action<EventHandler> subscribe = null)

Parameters

surface ISurface

UI element which should handle errors.

execute Action<object>

Action to run when command is invoked.

canExecute Func<object, bool>

Optional. Synchronous enablement test.

subscribe Action<EventHandler>

Optional. An Action<T> to use to subscribe to an event. The subscription will be stored in case the event uses the weak event pattern. When the event is raised, CanExecuteChanged will be raised. If null, no subscription will take place.

ShellCommand(ISurface, Action<ISurface, object>, Func<object, bool>)

protected ShellCommand(ISurface surface, Action<ISurface, object> execute, Func<object, bool> canExecute)

Parameters

surface ISurface
execute Action<ISurface, object>
canExecute Func<object, bool>

ShellCommand(ISurface, Func<ISurface, object, Task>, Func<object, bool>)

protected ShellCommand(ISurface surface, Func<ISurface, object, Task> executeAsync, Func<object, bool> canExecute)

Parameters

surface ISurface
executeAsync Func<ISurface, object, Task>
canExecute Func<object, bool>

Fields

Subscription

protected readonly EventHandler Subscription

Field Value

EventHandler

Methods

CanExecute(object)

Defines the method that determines whether the command can execute in its current state.

public bool CanExecute(object parameter)

Parameters

parameter object

Data used by the command. If the command does not require data to be passed, this object can be set to null.

Returns

bool

true if this command can be executed; otherwise, false.

Execute(object)

Defines the method to be called when the command is invoked.

public void Execute(object parameter)

Parameters

parameter object

Data used by the command. If the command does not require data to be passed, this object can be set to null.

OnCanExecuteChanged()

public void OnCanExecuteChanged()

RaiseCanExecuteChanged()

public void RaiseCanExecuteChanged()

Events

CanExecuteChanged

forward handlers to the command manager

public event EventHandler CanExecuteChanged

Event Type

EventHandler