Help with complex MVVM (multiple views)

Posted by jsjslim on Programmers See other posts from Programmers or by jsjslim
Published on 2014-01-16T09:51:12Z Indexed on 2014/08/23 4:27 UTC
Read the original article Hit count: 453

Filed under:
|

I need help creating view models for the following scenario:

  1. Deep, hierarchical data
  2. Multiple views for the same set of data
  3. Each view is a single, dynamically-changing view, based on the active selection
  4. Depending on the value of a property, display different types of tabs in a tab control

enter image description here

My questions:

Should I create a view-model representation for each view (VM1, VM2, etc)?

1. Yes:
    a. Should I model the entire hierarchical relationship? (ie, SubVM1, HouseVM1, RoomVM1)
    b. How do I keep all hierarchies in sync? (e.g, adding/removing nodes)

2. No:
    a. Do I use a huge, single view model that caters for all views?

Here's an example of a single view

Figure 1: Multiple views updated based on active room. Notice Tab control

enter image description here

Figure 2: Different active room. Multiple views updated. Tab control items changed based on object's property.

enter image description here

Figure 3: Different selection type. Entire view changes

enter image description here

© Programmers or respective owner

Related posts about wpf

Related posts about mvvm