Open sandboxFocus

Method CreateDelegateCommand

CreateDelegateCommand(Action, Func<bool>?)

Creates a synchronous command without a parameter.

Declaration
public static DelegateCommand CreateDelegateCommand(Action execute, Func<bool>? canExecute)
Parameters
Type Name Description
Action execute

The delegate to invoke when the command is executed.

Func<bool> canExecute

An optional delegate that determines whether the command can execute. If null, the command can always execute.

Returns
Type Description
DelegateCommand

A new DelegateCommand instance.

CreateDelegateCommand(Action, Func<bool>, INotifyPropertyChanged, string)

Creates a synchronous command without a parameter, with INotifyPropertyChanged integration for the CanExecute property.

Declaration
public static DelegateCommand CreateDelegateCommand(Action execute, Func<bool> canExecute, INotifyPropertyChanged canExecuteNotifier, string canExecutePropertyName)
Parameters
Type Name Description
Action execute

The delegate to invoke when the command is executed.

Func<bool> canExecute

A delegate that determines whether the command can execute.

INotifyPropertyChanged canExecuteNotifier

The object that raises PropertyChanged when the CanExecute property changes.

string canExecutePropertyName

The name of the property that controls CanExecute.

Returns
Type Description
DelegateCommand

A new DelegateCommand instance that automatically raises CanExecuteChanged when the specified property changes.

CreateDelegateCommand<T>(Action<T>, Func<T, bool>?)

Creates a synchronous command that accepts a parameter.

Declaration
public static DelegateCommand<T> CreateDelegateCommand<T>(Action<T> execute, Func<T, bool>? canExecute)
Parameters
Type Name Description
Action<T> execute

The delegate to invoke when the command is executed.

Func<T, bool> canExecute

An optional delegate that determines whether the command can execute for a given parameter. If null, the command can always execute.

Returns
Type Description
DelegateCommand<T>

A new DelegateCommand<T> instance.

Type Parameters
Name Description
T

The type of the command parameter.

CreateDelegateCommand<T>(Action<T>, Func<T, bool>, INotifyPropertyChanged, string)

Creates a synchronous command that accepts a parameter, with INotifyPropertyChanged integration for the CanExecute property.

Declaration
public static DelegateCommand<T> CreateDelegateCommand<T>(Action<T> execute, Func<T, bool> canExecute, INotifyPropertyChanged canExecuteNotifier, string canExecutePropertyName)
Parameters
Type Name Description
Action<T> execute

The delegate to invoke when the command is executed.

Func<T, bool> canExecute

A delegate that determines whether the command can execute for a given parameter.

INotifyPropertyChanged canExecuteNotifier

The object that raises PropertyChanged when the CanExecute property changes.

string canExecutePropertyName

The name of the property that controls CanExecute.

Returns
Type Description
DelegateCommand<T>

A new DelegateCommand<T> instance that automatically raises CanExecuteChanged when the specified property changes.

Type Parameters
Name Description
T

The type of the command parameter.