When you are passed the list of Transmission objects you can use the Façade pattern and store them in a container designed...
public class TransmissionContainer : INotifyPropertyChanged
{
private readonly Transmission _transmission;
public TransmissionContainer(Transmission transmission)
{
_transmission = transmission;
}
private int _id;
public int Id
{
[DebuggerStepThrough]
get { return _transmission.ID; }
[DebuggerStepThrough]
set
{
if (value != _transmission.ID)
{
_transmission.ID = value;
OnPropertyChanged("Id");
}
}
}
public bool Cancelled
{
[DebuggerStepThrough]
get { return _transmission.Cancelled }
[DebuggerStepThrough]
set
{
if (value != _transmission.Cancelled)
{
_transmission.Cancelled = value;
OnPropertyChanged("Cancelled");
OnPropertyChanged("Status");
}
}
}
public string Status
{
[DebuggerStepThrough]
get
{
StringBuilder sb = new StringBuilder("|");
if (_transmission.Cancelled)
sb.Append("| Cancelled ");
if (_transmission.Recorded)
sb.Append("| Recorded ");
if (_transmission.Stored)
sb.Append("| Stored ");
sb.Append("||");
return sb.ToString();
}
}
//
// code in other properties here
//
#region INotifyPropertyChanged Implementation
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string name)
{
var handler = System.Threading.Interlocked.CompareExchange(ref PropertyChanged, null, null);
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
This is a container class that creates a façade to which your Xaml can bind transparently. As shown, each of the exposed properties simply echoes back the value in the private instance of Transmission. Changes are relayed to the WPF binding engine via the INotifyPropertyChanged interface.
To create an instance you can construct it with the original Transmission class. To bind a collection of these containers, you can declare an ObservableCollection of type TransmissionContainer. Doing that means the list is bound in addition to the various changes in the properties.
In this approach, your 'extension' property is just another exposed property that has no setter. Note that changes to the other members that affect Status call the notification on behalf of the 'extension' property. Coding in the remaining members of the Transmission class should take about 20 minutes...