I am trying to get my head around MVVM. For a simple list->data view it’s no problem. But I am struggling to understand how multiple layers work. I sort of have something working but it’s very hit and miss as to which bits work and which bits don’t. For example, some data updates, some doesn’t. Anything in a deeper level which should affect a list at an upper level sometimes updates the list, sometimes doesn’t. There must be a pattern but I have yet to spot it. Does anybody know of any tutorials with more than just a list->data type of view?
Example:
List of widgets
+- Widget name
+- Widget description
+- List of Widget parts
+- Part ID
+- Colour
In that example I could have a three-column approach – list of widgets in the left, widget information in the middle including the parts list, and then the part detail on the right.
You should have multiple ViewModels, one for each level.
Then you can provide events to let the upper levels update on change.
For example you can have a
Having events (including a simple pattern) is described here Events in .Net
Furthermore, I recommend watching this excellent video tutorial on MVVM:
Jason Dollinger on MVVM
The video covers some issues of Unity also! (which could be very valuable for you)
The sourcecode he developes is also available:
Lab49 Sourcecode by Jason Dollinger