Method SetProperty
SetProperty<T>(ref T, T, string)
Sets the value of a property and raises the PropertyChanged event if the value has changed.
protected virtual bool SetProperty<T>(ref T storage, T value, string propertyName = null)
Parameters
storage
TThe reference to the backing field of the property.
value
TThe new value of the property.
propertyName
stringThe name of the property.
Returns
- bool
true
if the property value has changed; otherwise,false
.
Type Parameters
T
The type of the property.
SetProperty<T>(ref T, T, Action, string)
Sets the value of a property and raises the PropertyChanged event if the value has changed. Additionally, invokes the specified action when the property value has changed.
protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, string propertyName = null)
Parameters
storage
TThe reference to the backing field of the property.
value
TThe new value of the property.
onChanged
ActionThe action to invoke when the property value has changed.
propertyName
stringThe name of the property.
Returns
- bool
true
if the property value has changed; otherwise,false
.
Type Parameters
T
The type of the property.