how to implement backward navigation functionality through pages in winui3

shreshta valluru 86 Reputation points
2022-05-09T06:10:07.667+00:00

Using winui3 ,the backbutton should hold history of naviagtion through one page to another page ,on clicking backbutton it should navigate through pages how it was navigated through forward wihtout creating new instance in stack like mobile navigation

Windows development Windows App SDK
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2022-05-10T08:51:47.753+00:00

    Hello,

    Welcome to Microsoft Q&A!

    To implement what you need in your scenario, you need to make sure the rootfame handles all navigation actions, so when you click the backbutton, it can go back.

    Here are the steps:

    1) you need to handle the homepage_click event inside the mainWindow.cs, not in the homepage. So that you could use the rootframe object to navigate to the deletepage just like the same way you did for the homepage.

    2) you need to handle the backbutton event of the deletepage inside the mainWindow.cs, so you could use the rootframe object and call the rootframe.goback() method to navigate back.

    Besides, the simplest way is that do not add navigate button inside these sub pages. Handle the navigationview's iteminvoke event to navigate to different subpages when users click on the NavigationViewItem. You could easily access the rootframe to control all the navigation actions.

    Thank you.


    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2022-05-09T08:03:17.31+00:00

    Hi,

    Welcome to Microsoft Q&A!

    I suggest you could try to use the NavigationView control to provide the navigation framework for your app. If your app uses the NavigationView control, then you can use NavigationView's built-in back button.

    You could refer to the Doc: Navigation history and backwards navigation for Windows apps

    Best Regards,

    Jeanine


    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.


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.