在 wpf 和 mvvmlight 中导航的设置

发布于 2024-12-03 03:51:27 字数 271 浏览 2 评论 0原文

目前正在开始一个新的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稚然 2024-12-10 03:51:27

请参阅此答案了解对话策略。这应该适用于您的问题。但是,在使用上述场景中的消息时需要注意一点......调用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文