简体   繁体   English

导航如何与ViewModelLocator一起使用?

[英]How does navigation work with a ViewModelLocator?

I'm looking into the concept of ViewModelLocators, but found only basic tutorials that were dealing with one main View and one main ViewModel, which of course works fine. 我正在研究ViewModelLocators的概念,但只发现了处理一个主View和一个主ViewModel的基本教程,这些教程当然可以正常工作。

While I do understand how the concept of the ViewModelLocator itself works, I do not really understand how navigation would work with this. 虽然我确实了解ViewModelLocator本身的概念是如何工作的,但我并不真正了解导航如何与此一起工作。 I am used to use DataTemplates in Views that react to a bound ViewModel - when the bound ViewModel changes then a different view is shown. 我习惯于在视图中使用DataTemplates来对绑定的ViewModel做出反应-当绑定的ViewModel更改时,将显示另一个视图。 How would that be done with a ViewModelLocator? 使用ViewModelLocator怎么办? I was not able to find a nice tutorial example that deals with the question of navigation. 我找不到很好的教程示例来解决导航问题。

Could anyone of you provide me a tutorial how this is supossed work? 你们中的任何人都可以给我提供一个教程,介绍如何实现此目的吗? I somehow fail to understand this on my own. 我以某种方式无法自己理解。

A view model locator is not responsible for the navigation. 视图模型定位器不负责导航。

You would use a navigation service to navigate between the views from which the view models are resolved using the view model locator. 您将使用导航服务在使用视图模型定位器解析视图模型的视图之间导航。

The navigation service and the view model locator are two different components with different responsibilities. 导航服务和视图模型定位器是两个具有不同职责的不同组件。

You will find a brief example of how to use them both together here . 您将在此处找到有关如何将它们一起使用的简短示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM