2

上下文:
1. Windows Phone 7.5 及更高
版本 2. PageA 使用“this.NavigationService.Navigate(new Uri("/Help.xaml", UriKind.Relative));”导航到 PageB
3. PageB 使用 NavigationService.GoBack() 返回到 PageA;
4.在pageA中,我想检查它是否来自pageB

我使用“NavigationService.BackStack.FirstOrDefault();” 在 pageA 的 OnNavigatedTo 方法中,但由于 GoBack() 将删除源页面,我无法得到正确的结果?

pageA 如何知道它是从 pageB 导航回来的?

4

2 回答 2

0

基本上这是由 canGo Forward Prop 完成的。

void forwardButton_Click(object sender, RoutedEventArgs e)
{
    if (this.NavigationService.CanGoForward)
    {
        this.NavigationService.GoForward();
    }
}

如果 CanGoForward 为 false,则导航服务中没有转发堆栈

解决方法将页面名称保存在

Application.Current.Resources("LastPage", "MainPage.xaml");

并检查它是否可以前进,最后一个页面名称将指示您所在的页面

于 2013-09-15T10:41:43.020 回答
0

在 PageA 中,您可以覆盖该OnNavigatingFrom方法,参数的Uri值是作为导航来源的页面。

于 2013-09-15T12:51:47.800 回答