Unmanaged struct backed INPC ViewModel, only raising PropertyChanged when backing field(s) changed
So, suppose we have a large unmanaged struct that we obtain from external source, suppose from a network resource.
This unmanaged struct decomposes into a set of primitives, with various values.
and then we have our ViewModel class that implements INotifyPropertyChanged. I have made an example below, not using the above struct as a field.
I had a thought to in the View Model class just have a single field of the unmanaged struct, and then fire off events of property changed.
But if I were to do that, how would one determine which properties were changed ?
Would it be better to have the unmanaged struct as the sole backing field, or should I not do that?
2 Replies
I have decided to not do that, and set each property in turn, which is only raise the property changed events for that property efficiently, whereas having a single backing field would make raising the events more difficult.
✅ This post has been marked as answered!