重新加载PhoneApplicationPage [英] Reloading a PhoneApplicationPage
本文介绍了重新加载PhoneApplicationPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用silveright进行Windows Phone的应用程序,有时我需要重新加载屏幕上显示的同一页面。我正在使用PhoneApplicationPage类来构建我的页面。
Hi, I'm doing an application for windows Phone with silveright, and i need to, sometimes, reload the same page shown on screen. I'm Using the PhoneApplicationPage class to build my pages.
我有一个必须刷新同一页面的按钮,名为page6,所以当我点击它时我会调用一个应该按下的按钮事件刷新页面。有谁知道怎么做?
I have a button the must refresh the same page, named page6, so when i click it i call a button event that should refresh the page. Does anyone knows how to do it?
我已经尝试过这个:
NavigationService.Source = new Uri("/Page6.xaml", UriKind.Relative);//or this
NavigationService.Navigate(NavigationService.Source);//or this
Navigate(NavigationService.CurrentSource);
推荐答案
static int refreshCount;
void Button_Click(object sender, RoutedEventArgs e)
{
Debug.WriteLine(NavigationService.Source);
string url = NavigationService.Source.ToString();
if (!url.Contains("RefreshCount="))
{
if (NavigationContext.QueryString.Count < 1)
{
url += "?RefreshCount=" + ++refreshCount;
}
else
{
url += "&RefreshCount=" + ++refreshCount;
}
}
else
{
url = Regex.Replace(url, @"RefreshCount=+\d", "RefreshCount=" + ++refreshCount);
}
NavigationService.Navigate(new Uri(url, UriKind.Relative));
}
这篇关于重新加载PhoneApplicationPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文