在 wpf 和 mvvmlight 中导航的设置
目前正在开始一个新的wpf项目并想要使用mvvmlight。我最初的想法是在窗口顶部有 4 个按钮作为导航,然后是一个内容控件,从导航按钮中选择时将在其中注入新视图。
这是一个主窗口和一些将被注入的子视图。主虚拟机应该具有与导航按钮相连的命令。执行时,该命令应该发送一条导航消息来更改视图,这就是我感到困惑的地方。谁应该处理导航消息的发送和更改 ContentControl 中的视图?我猜 ViewModelLocator 仅用于实例化视图模型。
将其粘合在一起缺少什么?
此致
Currently getting started on a new wpf project and want to use mvvmlight. My initial thought was to have 4 buttons as navigation at top of the window and then a contentcontrol where new views would be injected when chosen from the navigationbuttions.
That is a mainwindow and som subviews that will be injected. The main VM should have commands hooked to wired up with the navigation buttons. When executed the command should send a navigation message to change a view, and this is where I get confused. Who should handle the navigation messages send and change the view in the ContentControl? I guess the ViewModelLocator is only for instantiating the viewmodels.
What is missing in getting this glued together?
Best regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅此答案了解对话策略。这应该适用于您的问题。但是,在使用上述场景中的消息时需要注意一点......调用 Unregistr() 尤其是在您的视图上。
See this answer for a dialog strategy. This should be applicable to your problem. However, one word of caution when using messages in the above szenario ... call Unregistr() especially on your views.