Data Layer

I have an Order class as an entity. This Order entity is my model object.

Order can be different types, let it be

  • A

  • B

  • C

  • D

Also Order class may have common properties like Name, Time of creation, etc.

Also based on the order type there are different fields that are not common.

View Layer

The view contains the following

  1. Main Menu
  2. ListView

The Main Menu contains the drop down menu button which is used to create the order based on the type selected from the drop down. The drop down contains the Order types ( A ,B , C and D).

There are different user control based on the order type. Like for example if user chooses to create an order of type A then different view with different inputs field is popped up.

Hence, there are four user control for each order type.

If user selects A option from the drop down then Order of type A is created and vica versa.

Now below is the List View that contains the List of orders so far created by the user.

To Edit any particular order user may double click the list view row. Based on the order type clicked by the user in the listview, the view of that order type opens in edit mode. For example if user selects an order type A from the list view then view for order type A open in edit mode.

Please suggest an interaction model for view models in the scenario discussed above.

Please excuse me if the query is very basic, since I am new new to MVVM and WPF.

2

There are 2 answers

0
kyoryu On

Rather than give you a specific design, I'm going to suggest a different way of looking at the problem.

Make your xaml. Now, if it could have the data organized in any way exposing any set of methods it wanted, what would that look like? Don't even think about the real structure of the entities when imagining this. More inheritance? Less? Up to you - whatever would be best for your View.

Okay, whatever you just described is your ViewModel. Write the public API for that. Then, hook it up to the actual underlying entities.

0
Andrew Bienert On

Is your main problem in how to create the correct View for the selected Order type? ie How does the drop down or the ListView trigger the correct Order view to be displayed.

If that's what you're getting at then you're going to want something like: When the user clicks on the list of Orders (for example) you'll need to change the some underlying ObservableCollection and send out some kind of notification or force it to do something on some kind of Workspace object. Probably the best way to understand that is to look at the MvvmDemoApp by Josh Smith as well as his article if you haven't already read it. From there zero in on the way he implements the WorkspaceViewModel as I think that might be the approach, or something like that, you are after for your Order view user controls. (if I've understood you correctly).