Nov 28, 2012 at 7:56 PM
Edited Nov 28, 2012 at 8:00 PM
Firt of all, I wish to thank you for the MVVM Foundation. It is extremely helpful!
I am fairly new to MVVM. I finally "figured" it out a few months ago, and I started with C# about a year and a half ago (all self thought), so please excuse any newbie mistakes in my coding (I do appreciate feedback
on things I am doing wrong).
In my recent project I needed an EditableObject which would also raise PropertyChanged when changes were discarded. For classes with only a few properties I would raise PropertyChanged manually when data was discarded. Eventually I had to handle classes
with many properties. Being the problem solver I am, I went on a journey to figure out a way around manually writing all the property changed calls. What I came up with is EditableObject which inherits from ObervableObject (should probably call it EditableObservableObject),
has all the Edit methods and automatically raises PropertyChanged on all the class properties that are decorated with ObservableProperty attribute.
After posting this code on Stack Overflow I started thinking that there must be a better way to go about this. Is there something I have missed during my MVVM learning phase? I searched for a solution online, but I could not come across anything. I have
a feeling that there may be a pre-existing elegant way about doing this.
Currently the issue is that even the properties that were not changed will have their PropertyChanged event raised. I feel that this could cause a performance hit for large objects. This is the same reason I refrained from raising the change with
an empty string, did not want unnecessary events being raised.
To cut down on wall of text, I am going to link to the SO answer that I posted earlier using this class.
Thank you for any feedback,