RelayValueCommand<TParameter, TValue>

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

Constructors

RelayValueCommand

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

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.

OnValueChanged

#
protected virtual void OnValueChanged(EventArgs e)
Raises the ValueChanged event.

SetValue

#
public void SetValue(object parameter, TValue value)
Sets the value.

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.

Events

ValueChanged

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