Page doesn't destroy/unload itself after OnNavigatedFrom

浪子不回头ぞ 提交于 2019-12-23 01:18:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!