Navigate through pages in mvvm in Silverlight 4
I have been searching on how to navigate through the pages in Silverlight 4 (navigation application) when I have implemented MVVM pattern. But nothing I found satisfied me.
I hav开发者_运维知识库e a main page which has frame in it. In that frame I load home page which does simple URI mapping. But now I want to go to New Page on button's click event.
I used this:
this.NavigationService.Navigate(new Uri("/NewPage", UriKind.Relative));
The concept of a PageConductor, as introduced by John Papa and improved upon in MEFedMvmm, I think is the most elegant solution.
http://www.riaservicesblog.net/Blog/post/MEFing-up-John-Papae28099s-MVVM-code-from-Firestarter.aspx
Take a look at this article (http://csharperimage.jeremylikness.com/2009/11/dynamic-module-loading-with-silverlight.html) written by Jeremy Likness.
He is using Prism and the Navigation framework and it's a good article to get you going with it. It's also not hard to take the sample he provides and apply some MVVM principals to it.
精彩评论