0
votes

I am creating a Windows 8.1 Universal App. I have three pages: Page 1,Page 2 and Page 3. I enabled the NavigationCacheMode inside the constructor on Page 2.

When i am navigating from Page 1(Login page) -> Page 2(Search screen) - > Page 3(Result Screen).

On Search screen, I am searching emails through API and then navigate to Result Page.When i press back button on result Page, my screen navigates to Page 2(Search Screen) with previous state which is okay.

But when I am logging out from Page 3(Result Page) itself then my screen would get navigates to Page 1(Login Page). and after then i again login then it would navigates to Page 2(Search Screen) but this time previous cached state of page are also there that should i don't want.

Means when i am navigating to fresh instantiated page, it captures the cached content from previous state when i was visited last time.

Suggest me. Any help would be appreciated.

2
When navigating to the second page, can you check NavigationEventArgs.NavigationMode in OnNavigatedTo override? If it's "New" you can clear the search term and search results – Igor Ralic
Yes i am checking Navigation mode. You mean to say that every time i have to clear all the objects manually again. – Vedank Kulshrestha

2 Answers

0
votes

Per my understanding, you would like to clear the page cache when a user logged out. If so, we can try to reset the cache by setting the Frame.CacheSize to 0 first and set back to the original value. There is a good example in Andreas Hammer's blog as below:

var cacheSize = ((Frame) Parent).CacheSize;
((Frame) Parent).CacheSize = 0;
((Frame) Parent).CacheSize = cacheSize;
0
votes

I would propose you to look at this Remove Pages windows phone where you can learn to remove pages. Further look into overriding the backkey event.