UWP 页面导航标识符

UWP Page navigation indentifier

Hello in UWP 我可以像这样导航到另一个页面:

Frame.Navigate(typeof(AnotherPage), someObject);

如果我想检索对象,在 AnotherPage 中:

protected override void OnNavigationTo(NavigationEventArgs e) {
    SomeObject someObject = (SomeObject) e.Parameter;
    //here I would like to know from what page I am navigating
}

你能告诉我如何找出我正在导航的页面吗?谢谢

导航完成后,上一页将被放入 Frame 的 BackStack,只需查询该集合即可。

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    SomeObject someObject = (SomeObject)e.Parameter;

    PageStackEntry previousPage = Frame.BackStack.Last();
    Type previousPageType = previousPage?.SourcePageType;

    base.OnNavigatedTo(e);
}