在 WPF MVVM 中的视图之间导航

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15576838/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:15:43  来源:igfitidea点击:

Navigating between Views in WPF MVVM

wpfvisual-studiomvvmblend

提问by Pranjal

I am new to WPF and MVVM and am working on an application which has a few views. Right now I have a View(HomePageView) shown in the shellView's context. Now using a button in the HomePageView I want to load another View in place of the currently shown HomePageView. After looking it up on google, I found something about Event Aggregators. I would request someone to explain the implementation or direct to a good sample application.

我是 WPF 和 MVVM 的新手,正在开发一个有几个视图的应用程序。现在我在 shellView 的上下文中显示了一个 View(HomePageView)。现在使用 HomePageView 中的一个按钮,我想加载另一个视图来代替当前显示的 HomePageView。在谷歌上查找后,我发现了一些关于事件聚合器的信息。我会要求某人解释实现或直接提供一个好的示例应用程序。

采纳答案by Viv

If your new to WPF MVVM I'd suggest first picking a decent helper tool

如果您不熟悉 WPF MVVM,我建议您首先选择一个不错的辅助工具

There are quite a few options. MVVM Light, Prism, MEF

有很多选择。MVVM 光、棱镜、MEF

I'd suggest MVVM light. Simple and easy to get up and running. Prism isnt solely a MVVM Helper but includes features to assist with MVVM. Not done much with MEF myself or things like Caliburn Micro.

我建议使用 MVVM 灯。启动和运行简单易行。Prism 不仅仅是一个 MVVM 助手,还包括协助 MVVM 的功能。我自己对 MEF 或 Caliburn Micro 之类的东西做得不多。

As for a sample to explain how navigation between views work with MVVM Light try:

至于解释视图之间的导航如何与 MVVM Light 一起使用的示例,请尝试:

http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views

http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views

MVVM Light on CodePlex:

CodePlex 上的 MVVM 灯:

http://mvvmlight.codeplex.com/

http://mvvmlight.codeplex.com/

^^ link has forwards to some video presentations totally worth watching

^^ 链接转发了一些非常值得观看的视频演示

Another nice sample using MVVM Light:

另一个使用 MVVM Light 的不错示例:

http://apuntanotas.codeplex.com/

http://apuntanotas.codeplex.com/

These should help you get started and you always got https://stackoverflow.com/questions/tagged/wpffor particular questions :)

这些应该可以帮助您入门,并且您总是可以针对特定问题获得https://stackoverflow.com/questions/tagged/wpf:)