Search code examples
c#xamlwindows-runtimewindows-store-appswinrt-xaml

WinRT - Navigate to specific page in the Navigation Stack


I have these pages on a windows project

page1.xaml

page2.xaml

page3.xaml

page4.xaml

After i do some operations on page1 i call this;

Frame.Navigate(typeof(page2), document);

On page 2 i do some stuff with the document, then i navigate to page3.xaml

Frame.Navigate(typeof(page3), document);

Then i do some more stuff on page 3 and go to page4.xaml.

And in page4.xaml i have a button that when pressed i want to go back to page2,xaml not a new one, but the same one i came from.

is this possible?


Solution

  • To navigate to the same instance of page2, you need to set the Page's NavigationCacheMode Property to Enabled or Required :

    NavigationCacheMode="Enabled" 
    

    now the difference between those two is whether or not they take CacheSize into consideration or not, from msdn :

    The difference in behavior is that Enabled might not be cached if the frame's cache size limit (CacheSize) is exceeded, whereas Required always generates an entry no matter the size limit.