The biggest benefit is that it allows a developer to create an application with no User Interface (UI). A Designer is then able to create the entire UI using Microsoft Expression Blend 4+, without writing a single line of code.
The benefits of this include:
To achieve this, all you need to do is create a UI (a View) that has no code behind, and communicates with the application using bindings and commands that are contained in a View Model.
The Model is where the data for the application goes, The Model can contain:
The View Model consists of:
This is the part that you can make with no code using Expression Blend.
To Learn View Model, Start Here: [RIATasks: A Simple Silverlight CRUD Example]
@Rustam - Sorry I don't.
Hi Michael,<br /><br />I followed your tutorial (RIATasks: A Simple Silverlight CRUD Example (using View Model)) and I found it very (VERY) useful. Thank you. Is there a tutorial for membership/roles when using Silverlight. Scott Mitchell wrote a great series (14 part) on membership/roles with asp.net. Is there a equivalent.<br /><br />Regards<br />Rustam (UK, Bournemouth)
@Jonah Kunz - All of this is just an opinion :) In my opinion, for Silverlight, the Model IS the Webservice (or Rest Service). In WPF it would be different. With WPF you most likely would not have web services so your Model would be a set of classes.<br />Some still make a set of classes to use as the Model for Silverlight and the web services just fill the Model. However, that is a lot of extra code for the same result, so I eliminate that and consider the Web services the Model.
I also just wanted to make sure I have this pattern down correct. In my Silverlight project I just call the Models from a web service right? So Models and methods are in the web service project?<br /><br />Thanks
HI,i have some confusion on this artical,that is the model part of MVVM pattern does not mean we put here all service calling concept indeed it is server side WEB-SERVICE That contains DATA.plz tell me is it right?
Just wanted to add my "nice post" comment to the list. Thanks!
I am doing a report for hiring a mentor, this article was very useful. I would thoroughly asber which negative and positive points between MVVM vs MVC?<br>thanks<br>Marcelo Sampaio (Brazil)
I would thoroughly asber which negative and positive points between MVVM vs MVC?<br>thanks<br>Marcelo Sampaio (Brazil)
@Vikas Rao - This article shows that dynamic controls work fine with MVVVM:<br><a href="http://www.codeproject.com/KB/silverlight/SuperTabs.aspx" rel="nofollow">www.codeproject.com/KB/silverlight/SuperTabs.aspx</a>
Nice article. Few thoughts/questions<br><br>What happens when the controls need to be dynamically created and updated. I don't think it can be achieved just using Blend without any code behind.
@Shekhar - The MVVM pattern will work fine with 200 screens.
Hi Michael,<br><br>This is really good article... Thanks a lot<br><br>I'm developing LARGE application (200+ screens) in SL4, I have checked many details on the web and found that to follow the MVVM pattern. Will that be correct decision ?
Kiran - <br><br>refer following link<br><a href="http://www.kunal-chowdhury.com/2010/11/using-eventtrigger-in-xaml-for-mvvm-no.html" rel="nofollow">www.kunal-chowdhury.com/2010/11/using-eventtrigger-in-xaml-for-mvvm-no.html</a>
@Kiran - Sorry due to my schedule I am unable to take requests
Wow...Really great... Thankyou so much .Can you please provide simple code for that : i mean small project .<br><br>when user clicks button UI will will display helloworld
Great!! really superb explanation.. Thanks a lot!!
Nice article, it solved my confusion on this pattern..thanks
nice one thanks...
A nice explanation. Thanks :)
@Dave Bartlett ... Although a great bonus of MVVM is the ability to hand the UI design to a "designer", in my experience the biggest case for MVVM is that it lends itself very well to testing!
great post...as the title says the explanation is really simplified
@Dave Bartlett - "View Model Style" is basically MVVM in regards to the separation of the View and the "View Model". The only reason for a different term is to avoid the arguments that arise when you use MVVM, but do not adhere to all of it's "generally understood" "rules". <br><br>"View Model Style" has no rules :)
Great post Michael. One thing that is unclear to me is that if the only goal of MVVM is to allow the UI to be developed independently of the rest of the application, why does the pattern describe a "View Model" approach when that would not impact the separation of the UI?
Very nicely explained. Concise and clear, thanks.