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

后端 未结 2 1611
佛祖请我去吃肉
佛祖请我去吃肉 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

    0 讨论(0)
  • 2021-01-23 12:04

    try this code

    var Frame = Window.Current.Content as Frame;
    Frame.Navigate(Frame.Content.GetType());
    Frame.GoBack();
    

    Source enter link description here

    0 讨论(0)
提交回复
热议问题