1

I am developing an app using Windows Phone 7. I have used MVVM for WPF app development before but was wondering if MVVM is suitable for WP7 app development too. If not can you please suggest some architectures\frameworks to refer to use in WP7.

If I use MVVM, how do we navigate from one page to another and set DataContext of the page to a ViewModel?

Thanks.

1

2 Answers 2

2

Absolutely!

There are tons of resources online that talk about MVVM use in Windows Phone Dev .. simply search.

Two prominent MVVM frameworks in use are:

Have fun!

1
  • Thanks. But I am not clear on how navigation happens from one page to another and do we not use DataTemplates to illustrate ViewModels like in WPF? Commented Oct 25, 2011 at 11:19
0

Data context can be set in the constructor of the .xaml page:

PageViewModel viewModel = new PageViewModel();
this.DataContext = viewModel;

Also, from what I know, interface related actions can be done in the view so for navigation you could simply subscribe to some event in the view and then:

PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;
frame.Navigate(new Uri("/Views/NewPage.xaml", UriKind.Relative));
1
  • 1
    Thanks for your reply Marius. Laurent has explained the use of MVVM pretty well in Mix 10 and 11 conferences ... channel9.msdn.com/Events/MIX/MIX11/OPN03. To be able to test navigation it is better to use a navigaition service and invoke that from ViewModel instead of from View Commented Nov 3, 2011 at 4:57

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.