简体   繁体   中英

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.

 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

this.NavigationCacheMode = NavigationCacheMode.Required;

and in OnNavigatedTo event handler , check your navigationMode and delete if you're doing something more than default initializing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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