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

377 views Asked by At

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?

1

There are 1 answers

0
Burak Kaan Köse On BEST ANSWER

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.