手机应用程序页面

手机应用程序页面

本文介绍了如何在不在内存中创建新副本的情况下重新加载 Windows 手机应用程序页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Windows 手机应用程序中,我尝试使用以下代码重新加载应用程序页面:

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

NavigationService.Navigate(new Uri(string.Format("/Page1.xaml?random={0}", Guid.NewGuid()), UriKind.Relative));

我已将上面的代码写入按钮单击事件.Page1 重新加载正常,但每次当我点击按钮时,应用程序内存不断增加,有时应用程序崩溃.

I have written the code above to the button click event. The Page1 is reloading fine but every time when I click the button the app memory keep on increasing and at some time app is crashed.

是否有其他方法可以重新加载或刷新页面,而无需在应用内存中创建页面的新副本.

Is there any other way to reload or refresh the page with out creating a new copy of the page in the app memory.

推荐答案

您始终可以通过调用 Page.Refresh(); 从代码中刷新页面内容;或一些类似的方法,但这可能不会刷新所有内容.

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();
   }
}

看看 NavigationService 类,特别是 AddBackEntry 和 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

这篇关于如何在不在内存中创建新副本的情况下重新加载 Windows 手机应用程序页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 05:14