How to get previouspage ,when page navigatedto

Fei Xu 490 Reputation points
2023-12-28T16:56:52.4866667+00:00

APage can navigate from B or C Page , then how can i know which it is from.

like the image , previouspage is that i wanted ,but it is nonpublic

20231229004346

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-12-29T02:08:42.9266667+00:00

    Hello,

    APage can navigate from B or C Page , then how can i know which it is from.

    If you use NavigationPage to navigate, you can get the previous page by

     List<Page> res = Navigation.NavigationStack.ToList<Page>();
     var PreviousPage=res[res.Count-2];
    

    If you use Shell, you can use Navigation events to get previous page by Previous property.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.