How to cache a page in Windows Phone 8.1

前端 未结 2 561
生来不讨喜
生来不讨喜 2021-01-13 21:44

Previously in Windows Phone 8.0 apps, we could navigate deeper to the same page this way:

NavigationService.Navigate(new Uri(\"/SamePage.xaml\",         


        
相关标签:
2条回答
  • 2021-01-13 22:07

    In App.cs you can set RootFrame.CacheSize which hints the OS how many pages it should try to keep in cache. Also you probably shouldn't reset the datacontext in NavigationHelper_LoadState - this method is called each time you navigate to the page, even if you navigate back.

    0 讨论(0)
  • 2021-01-13 22:17

    In your page constructor you'll have to specify

        public MainPage()
        {
           this.InitializeComponent();
           this.NavigationCacheMode = NavigationCacheMode.Required;
        }
    
    0 讨论(0)
提交回复
热议问题