Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a lot of different implementations and interpretations.</p> <p>In my mind, however, the value of the ViewModel comes from coordination. </p> <p>The <strong>Model</strong> is representative of business data. It encapsulates scalar information, as opposed to process.</p> <p>The <strong>View</strong> is obviously the presentation of the model.</p> <p>The <strong>ViewModel</strong> is a coordinator. In my opinion, the job of the view model is to coordinate between the view and the model. It should NOT contain business logic, but in fact interface with business services.</p> <p>For example, if you have a view that is a list of widgets, and the widgets are grabbed from a service, then I'd posit:</p> <p>The <strong>Model</strong> is a <code>List&lt;Widget&gt;</code> The <strong>View</strong> is a ListBox bound to the <strong>ViewModel</strong> property <em>Widgets</em> The <strong>ViewModel</strong> exposes the <em>Widgets</em> property. It also has a <strong>IWidgetService</strong> reference it can call to in order to get those Widgets.</p> <p>In this case, the view is coordinating with a business object so the view doesn't have to know anything about it. The model should be ignorant of view models, views, and every thing else ... they should exist independent of how they are used. The <strong>IWidgetService</strong> would get bound to the view model using some source of dependency injection container, either constructor injection with Unity or an import using MEF, etc.</p> <p>Hope that makes sense ... don't overload your viewmodel. Think of it as a coordinator that understands business objects and the model, but has no knowledge of the view or <em>how</em> business process is performed.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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