Click or drag to resize

ModelBaseUpdatePropertyT Method (ExpressionFuncT, Action)

Informs a property that it should invoke its OnPropertyChanged event.

Namespace:  Xcalibur.Extensions.MVVM.Models
Assembly:  Xcalibur.Extensions.MVVM (in Xcalibur.Extensions.MVVM.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public void UpdateProperty<T>(
	Expression<Func<T>> property,
	Action onChanged = null
)

Parameters

property
Type: System.Linq.ExpressionsExpressionFuncT
The property to be updated.
onChanged (Optional)
Type: SystemAction
Action to be performed after the update.

Type Parameters

T

Implements

INotifyUpdatePropertyT(ExpressionFuncT, Action)
Examples
C#
 1/// <summary>
 2/// Updates a property directly by comparing values and then firing its 
 3/// OnPropertyChanged event if necessary.
 4/// </summary>
 5/// <typeparam name="T"></typeparam>
 6/// <param name="propertyName">Name of the property.</param>
 7/// <param name="newValue">The new value.</param>
 8/// <param name="valueReference">The value reference.</param>
 9/// <param name="onChanged">The on changed.</param>
10public void NotifyOfChange<T>(string propertyName, T newValue,
11    ref T valueReference, Action onChanged = null)
12{
13    if (!Equals(newValue, null))
14    {
15        // If values are the same, exit
16        if (newValue.Equals(valueReference)) return;
17
18        // Assign new value
19        valueReference = newValue;
20    }
21    else
22    {
23        valueReference = default(T);
24    }
25
26    // Fire OnPropertyChanged
27    UpdateProperty(propertyName, onChanged);
28}
See Also