I am writing a C# app using the MVVM pattern and I was wondering what would be the best way to implement change tracking on a per property basis. I currently have INotofyPropertyChanged implemented and flag whether or not the whole object is dirty, but some of the requirements I have to implement is they want to be able to show an image by the text box on the UI for every property that has been changed.
Basically my View Models all have a private field that is my class containing the data from my DataAccess Layer. So basically a class will look like this:
private BusinessObj _data
public Name
{
get{ return _data.Name;}
set
{
if(_data.Name != value)
{
_data.Name = value;
PropertyChanged("Name");
IsDirty = true;
}
}
}
My data access layer is basically serializing and deserializing XAML profiles for configuring our products.
You can use
ObservableCollectionin your Model Class and have your UI subscribe the event when the observable business data collection changed.in Model View
in UI