Reputation: 1017
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.
Upvotes: 2
Views: 1536
Reputation: 10015
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);
}
Upvotes: 6