如何向后导航并刷新我导航到的页面?

时间:2014-07-07 23:35:42

标签: c# windows-phone-8

我正在使用App.RootFrame.GoBack();但它不刷新页面(这是有道理的)。

我想强制执行页面刷新...无论如何这样做?

3 个答案:

答案 0 :(得分:1)

this可能重复。

无论如何,您可能希望使用NavigationService,如下所示:

if(NavigationService.CanGoBack())
{
    NavigationService.GoBack();
}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // ensure view has the data it needs
}

答案 1 :(得分:0)

这似乎做得很好。

IEnumerable<JournalEntry> pages = App.RootFrame.BackStack;
string pageURL = pages.First().Source.OriginalString;
App.RootFrame.Navigate(new Uri(pageURL + "?Refresh=true&random=" + Guid.NewGuid(), UriKind.RelativeOrAbsolute));

答案 2 :(得分:0)

on&#39; GoBack()&#39;将运行OnNavigatedTo()方法,但页面的构造函数不会。因此,您需要在OnNavigatedTo()方法中自己刷新页面。

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // Refresh the data in here
}

另外我怀疑你会更好地使用导航服务返回,即:

NavigationService.GoBack();
相关问题