简体   繁体   English

WinRT-导航到导航堆栈中的特定页面

[英]WinRT - Navigate to specific page in the Navigation Stack

I have these pages on a windows project 我在Windows项目上有这些页面

page1.xaml page1.xaml

page2.xaml page2.xaml

page3.xaml page3.xaml

page4.xaml page4.xaml

After i do some operations on page1 i call this; 在第1页上执行一些操作后,我称之为:

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

On page 2 i do some stuff with the document, then i navigate to page3.xaml 在第2页上,我对文档进行了一些处理,然后导航到page3.xaml

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

Then i do some more stuff on page 3 and go to page4.xaml. 然后我在第3页上做更多的事情,然后转到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. 在page4.xaml中,我有一个按钮,当按下该按钮时,我想回到page2,xaml,不是一个新的按钮,而是我来自的那个按钮。

is this possible? 这可能吗?

To navigate to the same instance of page2 , you need to set the Page's NavigationCacheMode Property to Enabled or Required : 要导航到page2的相同实例,您需要将Page的NavigationCacheMode属性设置为EnabledRequired

NavigationCacheMode="Enabled" 

now the difference between those two is whether or not they take CacheSize into consideration or not, from msdn : 现在这两者之间的区别在于,是否从msdn中考虑了CacheSize

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. 行为上的差异是,如果超出了帧的缓存大小限制(CacheSize),则可能不会缓存Enabled,而无论大小限制,Required始终会生成一个条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM