简体   繁体   English

ViewModel在导航Back Prism MVVM Windows Phone 8.1 C#上调用

[英]ViewModel Called on Navigation Back Prism MVVM Windows Phone 8.1 C#

I'm working on an application and everything works fine but when I go back to the previous page the View Model is called so it will not maintain the old data. 我正在开发一个应用程序,并且一切正常,但是当我返回上一页时,将调用视图模型,因此它不会维护旧数据。

I use this line to call My View Model in XAML. 我使用此行在XAML中调用“我的视图模型”。

 prismmvvm:ViewModelLocator.AutoWireViewModel="true"

So my question is: 所以我的问题是:

How do I disable the call of the View Model when I go back? 返回时如何禁用视图模型的调用?

You're referring caching here. 您在这里指的是缓存

In the constructor of your ViewModel , set your NavigationCacheMode 在ViewModel的构造函数中,设置NavigationCacheMode

this.NavigationCacheMode = NavigationCacheMode.Required;

and in OnNavigatedTo event handler , check your navigationMode and delete if you're doing something more than default initializing. 并在OnNavigatedTo事件处理程序中,检查您的navigationMode并删除(如果您要执行的操作不是默认初始化)。

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

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