Reputation:
Is there a guide somewhere showing an example of using ViewModels in a WP7 application?
Upvotes: 0
Views: 1031
Reputation: 755
While MVVM is really a great pattern (and will be even more important with Silverlight 5!), I would really consider twice if this is appropriate for your WP7 application.
Reasons:
No "Command" property for ButtonBase (it's SL3! Command was new in SL4). Therefore no easy use of Commanding-Pattern. You need to use RelayCommands, DelegateCommands or similar.
No Commanding-Pattern at all for items in the Application Bar (ApplicationBarButton or ApplicationBarMenueItem). Not even with RelayCommands, as the ApplicationBarItems do not derive from DependencyObject. :( (see http://blog.galasoft.ch/archive/2010/04/09/using-commands-with-applicationbarmenuitem-and-applicationbarbutton-in-windows-phone-7.aspx)
Dealing with Background-Threads, Dispatcher, etc. can be really cumbersome together with MVVM.
That doesn't mean, you shouldn't use MVVM! But check out carefully, whether MVVM is a benefit for your project or an additional burden that makes depelopment over-complicated.
HTH
Upvotes: 0
Reputation: 14882
You could check out Laurent Bugnion's EX14 - Understanding the MVVM Pattern - from Mix 10.
Laurent is the author of the popular MVVM Light Toolkit with support for WP7
Here's another couple of posts that may be of interest.
C#er : IMage: Model-View-ViewModel (MVVM) Explained
.NET by Example: Using MVVM Light to drive a Windows Phone 7 / Silverlight 4 map viewer
And this post gives you an overview of some of the MVVM Frameworks available.
JAPF » Blog Archive » Discover and compare existing MVVM frameworks !
Upvotes: 1