Sometimes, when I plan to create a program using this architectural pattern, I've got a lot of difficulties when I'm in the View Model phase.

I'm using WAF Framework to develop this architectural pattern. I'm a still a newbie.

Before you start, do you create all the UML design or do you use another tool to help you? How do you handle the design of your ViewModels ?

  • Do you have difficulties with MVVM in general or just with the step where you have to create your ViewModels ? You may have to reformat your question to make it clearier.
    – Matthieu
    Dec 22, 2011 at 20:33
  • Only in the view models.. Dec 22, 2011 at 20:44
  • What, specifically, are you having trouble with when it comes to view models? That information would help us answer your question better.
    – Rob
    Dec 22, 2011 at 20:54
  • @OscarFimbres : Reworked your question to go straighter to the point about the view models.
    – Matthieu
    Dec 22, 2011 at 21:08

1 Answer 1


The ViewModel is an abstraction of the View.

That means you need to know first what you want to diplay to the user. At least you should have a detailled sketch of what the UI will look like (There are many tools intended to do this: MS Expression Blend, Balsamiq, etc.). Or even a dummy UI without logic plugged behind, created with your development tool.

Once you have your view, the ViewModel will be the place to hold every binded value, and what could be called display logic, mainly formatting. A View Model can be a representation of one Model, a group of Models of the same type, or an aggregation of different models.

A simple exemple of View Model is the editing screen with a drop down list. Let's have a concrete example with a User that can be linked to a division :

public class UserModel 
   public string Username { get; set; } 
   public string EmailAddress { get; set; } 
   public int DivisionId { get; set; } 

public class DivisionModel 
   public int DivisionId { get; set; } 
   public string DivisionName { get; set; } 

It wouldn't make sense to plug an IEnumerable of divisions in UserModel, so we create a View Model to represent a displayable User, with all the data needed to have a working screen where I can select a Division for that User :

public class UserViewModel 
   public UserModel User { get; set; } 
   public IEnumerable<DivisionModel> Divisions {get; set;} 

And that's it. Depending on the language I'll be using, I'll just have to feed a drop down list with the IEnumerable of DivisionModels and make it show the Name member.

  • +1 Basically sketch out your View, then take all the data from your sketch and put it in your ViewModel. So if your View lets users edit User data, you'll want a UserModel in your ViewModel. If the View has a DropDown to select a User to edit, you'll want a list of Users for the DropDown, and something to track the SelectedItem (can be either an int for Index or User for user object). If you have a Save button, you'll want an ICommand for the Save functionality.
    – Rachel
    Dec 22, 2011 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.