Silverlight Navigation using Mvvm-light(oobe)+MEF?

北城余情 提交于 2019-12-23 12:20:15

问题


What is the best approach for navigating between UserControls/Pages(out of browser experience)? I'm fairly new to Silverlight and even newer to the mvvm pattern.

How well does the Navigation Framework Integrate with the MVVM Light Toolkit? A snippet for general application flow control with the two would be great.

The plan was to use the Navigation Framework for general flow or using Jeremy Likeness's approach to region management(http://csharperimage.jeremylikness.com/search/label/regions) and swapping out regions as needed. I've seen a few places mention replacing the Visual Root, but that sounded like a hack to me.

Any advice, snippets, or a nudge in the general direction would be greatly appreciated.

Thank you.


回答1:


You may find the following post useful: SL4 Navigation Template with MVVM Light




回答2:


I had the same problem and found this link (applies to Silverlight too):

Windows Phone 7 — Navigation between pages using MVVM Light Messaging




回答3:


I'm struggling with the same thing, However, I am kinda steered away from the "NavigationService" because allegedly the journal keeps the object reference in memory or something I read somewhere.

I've been trying to utilize a frame in the main window, and using mvvm light to send navigation messages to the window to change the frame.

Edit: I figured it out.

In the main window (code behind, not viewmodel) I added a Messenger.Default.Register(Of NotificationMessage(Of NavMsg))...

Then in ANY view model I do a Messenger.Default.Send(Of Notificationmessage(Of NavMsg))...

And then I created a NavMsg class which accepts a string uri or an object to navigate to.

Here's some T4 code templates to generate you the code for your view/viewmodel to work with mvvmlight and it demonstrated the closing window message above. http://dl.activeaspsoftware.net/dl.aspx?f=MvvmLightCodeTemplates.zip



来源:https://stackoverflow.com/questions/2741820/silverlight-navigation-using-mvvm-lightoobemef

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!