What is this ViewModel?
Join the DZone community and get the full member experience.Join For Free
The way I view MVVM is like this. It separates the Data(Model), from the presentation(View) and the ViewModel handles updating the Data when something changes on the View. It is useful, but I also feel if you are doing simple little apps you don’t need to use MVVM as it just takes up to much time and resources. But it is still a good thing to know and understand.
If you have checked out my previous posts and followed along, you should have noticed folders in the project that separated the Model, View and ViewModel out. If you wanted you could also check out the MVVM example from here (http://msdn.microsoft.com/en-us/library/ff431744(v=VS.92).aspx#BKMK_Common) also check out this short video if you want.
So if you start to notice in those examples, the view uses the ViewModel to get and set data to display and change, and the ViewModel updates the Model when it is saved. They do this as seperation of data and presentation. Separation helps with cleaner looking code and also has the ability to have a designer working on the View while a developer works on the data and that. But like I mentioned before if you are building a simple app, doing it in MVVM can cause a lot of overhead that isn’t really needed, but I still encourage you to try building an app with the MVVM pattern to get use to it.
I am still learning MVVM and have only had so much experience with
it, but if you plan on really getting into WP7 application development, I
suggest you read up on MVVM and try to build an app using the MVVM
pattern. Any suggestions for me about MVVM or any questions please let
Published at DZone with permission of Andrew Conlisk, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.