If you want the lazy and easy way of doing this, then @Burimi is correct in that you need to manage this within your class setters and getters.
You will have to, excuse the expression but, "old school" your class/object properties back to having a public getter and setter that accesses a private variable. Within the public setter, is where you would set your object's dirty flag, as well as your private variable... but you have to do it for every property that matters, one by one... I personally think this warrants one of these in the future:
public string FirstName { get; set => { this.isDirty=true; } }
Which would basically equate to the same as the current { get; set; }
, but also, if either of these have a =>
next to it, it would equate to and run this code at after //getting or setting it
but I don't even know if this is something that people would like to have or not nowadays.
public class myObject
{
public bool isDirty { get; set; }
private string FirstName_ = "";
public string FirstName { get { return FirstName_; } set { FirstName_ = value; isDirty = true; } }
}
Now, any time FirstName_
is changed, the entire object becomes dirty... rinse repeat.
Of course if you also wanted to report up, as it happens, all you have to do is fire a notify event that you created yourself and has the data you need... here's an example of what I mean:
public class myObject
{
public bool isDirty { get; set; }
private string FirstName_ = "";
public string FirstName { get { return FirstName_; } set { FirstName_ = value; isDirty = true; RaisePropertyChanged("FirstName"); } }
#region use YOUR_OWN_NOTIFY_EventHandler
public event YOUR_OWN_NOTIFY_EventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
YOUR_OWN_NOTIFY_EventTHandler handler = PropertyChanged;
if (handler != null) handler(new myPropertyChangedEventArgs(propertyName));
}
#endregion
}
Hope this helps someone...