How To Navigate Among Pages In UWP

Here are the steps for Navigation in UWP,

  • Create a new UWP project

  • Go to add new item and add 3 'Blank Pages', page1, page 2 and page3 respectively as shown below,

    add new item

  • Now add two stackpanels and a frame in it and name the frame to refer it later.
  • Add Home, Back and Forward buttons in the stackpanel and assign click events to them.

    stackpanel

  • Go to the constructor of MainPage.xaml.cs and type MyFrame.Navigate(typeof(Page1));, So the first page loads as the application runs.

    mainpage

  • Copy the same code in home button click event.

    button

  • Go to Page1.xaml and create a button and a textblock.

    textblock

  • Go to Page2.xaml and create a button and a textblock.

    textblock1

  • Go to page2.xaml.cs click event and write Frame.Navigate(typeof(Page3));

    navigate

  • Go to page1.xaml.cs click event and write Frame.Navigate(typeof(Page2));

    navigate

  • Go to page3.xaml and create a textblock.

    textblock

  • Now go to MainPage.xaml.cs and write the following code to make the navigation work.

    mainpage

  • Now run the program and see the navigation in work.

    navigation

Source Code:

Up Next
    Ebook Download
    View all
    Learn
    View all