RelayValueCommand<TValue>

RelayValueCommand<2>RelayCommand<1>
public class RelayValueCommand<TValue> : RelayValueCommand<object, TValue>
A IValueCommand<T> class that uses delegates for getting and setting the value of the command
Remarks: This can be used to delegate the getting/setting of the value to separate methods. Call RelayValueCommand<TParameter, TValue>.UpdateValue() to signal that the value has changed.
TValue
ValueCommand<T>

Constructors

RelayValueCommand

#
public RelayValueCommand(Func<TValue> getValue, Action<TValue> setValue, Action execute = null, Func<bool> canExecute = null)
Initializes a new instance of the RelayValueCommand class.
getValue (Func<TValue>)Delegate to get the value.
setValue (Action<TValue>)Delegate to set value.
execute (Action = null)Delegate to call when the command is executed (which usually changes the value).
canExecute (Func<bool> = null)Delegate to call to determine if the command can be executed.

Methods

CanExecute

public bool CanExecute(object parameter)
Determines whether this command can execute with the specified parameter.
inherited fromRelayCommand<T>
parameter (object)Command argument from the control.
true if this command can execute; otherwise, false.

Execute

public void Execute(object parameter)
Executes the command with the specified parameter.
inherited fromRelayCommand<T>

GetValue

public TValue GetValue(object parameter)
Gets the value.
inherited fromRelayValueCommand<TParameter, TValue>

SetValue

public void SetValue(object parameter, TValue value)
Sets the value.
inherited fromRelayValueCommand<TParameter, TValue>

UpdateCanExecute

public void UpdateCanExecute()
Tells consumers of this command that the RelayCommand<T>.CanExecute(object) state has changed and should be queried again.
inherited fromRelayCommand<T>

UpdateValue

public void UpdateValue()
Signals that the value has been updated and the delegate to get the value should be called.
inherited fromRelayValueCommand<TParameter, TValue>

Events

ValueChanged

public event EventHandler<EventArgs> ValueChanged
Event to signal to the control/widget that the value has been changed.
inherited fromRelayValueCommand<TParameter, TValue>
Remarks: Controls should call RelayValueCommand<TParameter, TValue>.GetValue(object) when this is raised so that they can set the state of the control to match the value provided.
ValueChanged