Derive LabelledValue<T> from PropertyChangedBase

This commit is contained in:
Antony Male 2014-04-15 12:39:23 +01:00
parent 6a1e8e688e
commit ae371cc42f
1 changed files with 15 additions and 5 deletions

View File

@ -10,22 +10,32 @@ namespace Stylet
/// Key-value pair useful for attaching labels to objects and displaying them in the view /// Key-value pair useful for attaching labels to objects and displaying them in the view
/// </summary> /// </summary>
/// <typeparam name="T">Type of the value</typeparam> /// <typeparam name="T">Type of the value</typeparam>
public class LabelledValue<T> : IEquatable<LabelledValue<T>> public class LabelledValue<T> : PropertyChangedBase, IEquatable<LabelledValue<T>>
{ {
private string _label;
/// <summary> /// <summary>
/// Label associated with this item. This is displayed in your View /// Label associated with this item. This is displayed in your View
/// </summary> /// </summary>
public string Label { get; set; } public string Label
{
get { return this._label; }
set { SetAndNotify(ref this._label, value); }
}
private T _value;
/// <summary> /// <summary>
/// Value associated with this item. This is used by your ViewModel /// Value associated with this item. This is used by your ViewModel
/// </summary> /// </summary>
public T Value { get; set; } public T Value
{
get { return this._value; }
set { SetAndNotify(ref this._value, value); }
}
public LabelledValue(string label, T value) public LabelledValue(string label, T value)
{ {
this.Label = label; this._label = label;
this.Value = value; this._value = value;
} }
public bool Equals(LabelledValue<T> other) public bool Equals(LabelledValue<T> other)