简体   繁体   中英

UWP Page navigation indentifier

Hello in UWP I can navigate to another page like:

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

and in AnotherPage if I want to retrieve the object:

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

Could you tell me how to find out from what page am I navigating? Thanks.

When navigation is done, the previous page gets put on the Frame's BackStack, simply query that collection.

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

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

    base.OnNavigatedTo(e);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM