How to reload a Windows phone application page without creating a new copy in the memory?

后端 未结 2 1612
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 11:04

In my Windows phone application, I\'m trying to reload the application page by using the following code:

NavigationService.Navigate(new Uri(string.Format(\"/Page         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-23 11:46

    You can always refresh the content of the page from code by calling Page.Refresh(); or some similar method, but this may not refresh all the content.

    If you decide to do a new navigation (and ensure that everything gets to the initial state of the page), you can remove the previously navigated pages from the stack by calling:

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
       if (NavigationContext.QueryString.ContainsKey("logedin"))
       {
           NavigationService.RemoveBackEntry();
       }
    }
    

    Take a look at the NavigationService class, specially the AddBackEntry and RemoveBackEntry methods:

    http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice(v=vs.110).aspx

提交回复
热议问题