Click here to Skip to main content
15,886,689 members
Articles / Desktop Programming / XAML
Tip/Trick

How to Navigate Among Pages in UWP

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
1 Dec 2015CPOL 23.6K   3   3
Explains how to navigate among pages with button clicks
  • Create a new UWP project.
  • Go to add new item and add 3 'Blank Pages', page1, page2 and page3 respectively.

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

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

  • Copy the same code in home button click event:

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

     

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

     

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

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

  • Go to page3.xaml and create a textblock:

     

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

     

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

     

Source code: https://github.com/umerqureshi93/Navigation

Personal blog: http://csdebugger.blogspot.com/

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionThanks! Pin
BajaPaul5-Mar-16 7:59
BajaPaul5-Mar-16 7:59 
PraiseRe: Thanks! Pin
Umer Qureshi12-Mar-16 9:09
professionalUmer Qureshi12-Mar-16 9:09 
QuestionImages offsite Pin
Nelek2-Dec-15 4:19
protectorNelek2-Dec-15 4:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.