Page doesn't destroy/unload itself after OnNav

2019-06-03 23:31发布

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:

Image of memory usage

(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条回答
\"骚年 ilove
2楼-- · 2019-06-03 23:59

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.

查看更多
登录 后发表回答