问题
I am using a frame to show my current page. The user can switch between two pages.
I navigate to the pages via:
frame.Navigate(typeof(FirstPage));
and
frame.Navigate(typeof(SecondPage));
I thought that every time I switch between the pages the old page will be destoyed/unload all it's content.
But looking on the memory usage, it doesn't look like it:

(every time I navigate to the SecondPage
I run the garbage collector so you can see when a navigation occured)
Do I have to change the frame.Navigation()
method or do I have to add something to the OnNavigationFrom()
method?
回答1:
If you don't want the app to cosume much memory after navigation, just set the NavigationCacheMode property on your pages to NavigationCacheMode.Required
.
Your app will not be creating new instances of the pages everytime you navigate to them.
来源:https://stackoverflow.com/questions/41531190/page-doesnt-destroy-unload-itself-after-onnavigatedfrom