Commanding Quickstart: PresentationModel

Oct 22, 2008 at 5:40 PM
In the Commanding Quickstart there are two PresentationModel classes: OrderPresentationModel and OrdersEditorPresentationModel.  It would appear to me that they have slightly different purposes in that OrdersEditorPresentationModel actually depends on the OrderPresentationModel and it also has a direct reference to the View.  Wouldn't that make it more of a Presenter than a PresentationModel?

Is the union of these two classes the PresenterModel or am I completely off track?
Oct 23, 2008 at 2:58 PM



The purpose of the Presentation Model class is to act as an UI model (like a façade for the domain model) with UI-specific state and behavior, by encapsulating the access to the model and providing a public interface that is easy to consume from the view (for example, using data binding).


For example, the OrdersEditorPresentationModel exposes an Orders property (of type ObservableCollection<OrderPresentationModel>) which is used to set the Model property of the OrdersEditorView. The Model property sets the DataContext of the view, so that the Orders collection can be bound to the ItemsSource of the ListBox in XAML. In that way, this collection is easily consumed from the view (taking into account that the OrderPresentationModel has a data template for its visual content), whether you use a concrete view or a data template.


For more information on the Presentation Model, you may have a look at this link: Presentation Model.


Hope it helps.


Ignacio Baumann Fonay