Take the 2-minute tour ×

I learning WPF MVVM pattern for couple of weeks already. I still don't have clear understanding of this pattern.

I've read this topic What applications could I study to understand (Data)Model-View-ViewModel? and almost all referenced articles.

The problem with all examples is that they have "a lot of extra stuff" (menus, several views etc. etc.) It's good when you need to learn how to do complex things, but it is not good when you looking for something you can start with.

I would like to have an application which I can use as skeleton to build my own application. I.e. I would like to see an application which has only absolutely mandatory things, that would be I suppose:

  • Main window
  • Model class
  • ViewModel class
  • View class
  • some ICommand implementation? (am I need something like that)?
  • probably I'm missing something
share|improve this question

closed as not constructive by Will Nov 18 '11 at 12:08


4 Answers 4

Part of the problem is, if you think about it, most of these aren't anything specific.

If you want only the "pure requirements", pretty much the only thing you'll need is some ICommand implementation. This is because the following are just standard WPF or C# classes:

  • Main Window -> Just use a Window
  • Model class -> This is your normal project data. Shouldn't be changed for MVVM
  • ViewModel class -> This is just a normal C# class that implements INotifyPropertyChanged
  • View class -> Standard WPF UserControl

The only thing you kind of need is an ICommand implementation that routes delegates to an ICommand. This can be ripped out of any MVVM framework (they all have at least one, but usually two implementations, one for Action and one for Action<T>, where the argument is routed from CommandParameter).

If you need a simple implementation of the command, you're welcome to steal the one from the code of my MVVM Series. The code for it isn't trying to be a "framework", since the goal was to show just the basics of MVVM.

share|improve this answer
well then I'm looking for application that has all these stuff pre-created. It would be ok to have a model that has String getHelloWorld method, several classes for view and viewmodel, one button on the view, command "showHelloWorld" bound to ViewModel and button... –  javapowered Nov 17 '11 at 20:33
@javapowered There would be no appropriate "model" - The model should already exist, since it's your specific domain logic and data. The other bindings/setup would all just be something you rip out every time, since they're going to be setup specific to your data. Really, the only thing left is what you get from doing a standard WPF application (which does the main window), and adding a class (VM) and a UserControl. Most framework templates setup all of their plumbing for their messaging services, etc... so they're going to be much more elaborate. –  Reed Copsey Nov 17 '11 at 20:34
@javapowered The closest thing out there is probably the WPF Toolkit, but you'll find you end up just ripping everything out of the template for pretty much every project: wpf.codeplex.com/… –  Reed Copsey Nov 17 '11 at 20:35
it seems it doesn't work with VS2010, i'm trying this now visualstudiogallery.msdn.microsoft.com/… –  javapowered Nov 17 '11 at 20:52

Check out this video by Jason Dollinger on MVVM. It's a small example that goes through the process of creating a non-ideal implementation, and then how to do it properly using MVVM. I found it very useful when starting out on MVVM. I thought the video was solid enough that I didn't even need to look at the source, but that is available as well.

share|improve this answer
i've seen this video, it's diffenetly helpful. however I searching for a project that I can just open in VS and use as a skeleton for my application –  javapowered Nov 17 '11 at 20:30

look at this cool toolkit

MVVM Light Toolkit http://www.galasoft.ch/mvvm/

share|improve this answer

I wrote a very basic MVVM example here if you're interested.

When I first started learning MVVM I had the same problem you did... I couldn't find any simple resources to explain the very basics of MVVM. It was even harder when I was trying to explain the MVVM design pattern to someone else, so this was a sample app I put together for him. I thought it was fairly simple and straightforward, so posted it online.

Edit: The actual "MVVM skeleton" I usually use looks more like the code found in this link. The first link was an extremely mvvm simple app with a single page, however the 2nd one starts with an AppViewModel which can handle switching Views.

share|improve this answer
thanks, I will check it. well I need something very general. it should be like VS template - "Create MVVM WPF application" which will create only mandatory things and nothing else. –  javapowered Nov 17 '11 at 20:34
@javapowered You can download the source code too, which can be used as a skeleton app. The startup objects in the example is a ProductViewModel and ProductView, but you can change them to whatever you want. It also includes generic objects you'll need such as a RelayCommand and NotificationObject (object that implements INotifyPropertyChanged). I would actually suggest getting into Microsoft's PRISM library, or the MVVM Light Toolkit once your comfortable with MVVM, but I wanted to keep the example simple and leave 3rd party libraries out of it. –  Rachel Nov 17 '11 at 20:45
@javapowered: Read this article: msdn.microsoft.com/en-us/magazine/dd419663.aspx. Then do what Rachel suggested. Get into the frameworks, they help you out a lot, even if you don't use all their pieces. PRISM is my favorite. It makes creating modular, decoupled applications very easy. It has a learning curve to it to understand how to set things up and get the ball rolling, but once you understand it it's amazing. The guide is well put as well. It does a great job of dividing up the key areas it addresses: Modularity, Navigation, Communication, Dependencies, etc. –  m-y Nov 17 '11 at 21:26
@m-y isn't Prism something complex? My software supposed to be pretty small and easy. Just several screens. I will write it myself. And Prism states that: "In short, these applications are "built to last" and "built for change." Applications that do not demand these characteristics may not benefit from using Prism." –  javapowered Nov 17 '11 at 22:23
@javapowered: There was no way I would be able to know that. Plus, nothing wrong with knowing how to use a framework for other future apps. –  m-y Nov 18 '11 at 2:56
