Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create the ViewModel(s) for many Views sharing the same Model?
    primarykey
    data
    text
    <p>This is based on the example from the book: Pro WPF and Silverlight MVVM by Gary McLean Hall</p> <p>where the author only insists on how to create the Model for a DB structure (and how to implement the DAL for it).</p> <p>I am looking for the correct way to create the ViewModel(s).</p> <p>Here is the <a href="https://picasaweb.google.com/Florin.Dimulescu/MVVM?authuser=0&amp;authkey=Gv1sRgCK-Uu4619afnRA&amp;feat=directlink" rel="nofollow">database model and the MVVM Model</a>- I suspect it is not quite complete, but the Product is missing the ProductCode:</p> <p>My Views will be: Pages displaying / editing views for Products, Customers and Orders I am familiar with the Models / ViewModels implementing / using the INotifyPropertyChange and ObservableCollection, no need to insist on that.</p> <p>My questions:</p> <ol> <li>How to create the ViewModels in such a way that they would all share the same model</li> <li>How do I manage the ViewModels? Do I have one Main ViewModel which aggregates all the specific ones? This relates to ViewModel state saving and restoring.</li> </ol> <p><strong>I am particularly interested in how to deal with this</strong>: the Model for Order has a List of Products. I will also have to maintain a list of Products for my ProductsViewModel which supports the displaying / editing Views for the Products. How can all be synchronized? Should the OrderModel only have a List of ProductCodes instead? What are the implications in that case?</p> <p>In general, the thing I am after here is: <strong>how to create and manage the ViewModels for Models which implement DB tables with many to many relationships (like Product-Orders)</strong>. Do we use only the foreign keys as part of the Model objects or do we use a reference to a whole other Model object represented by that foreign key?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload