Win 8 Page Navigation

Let’s start with something relatively easy… navigating between pages in Windows 8.

Create a new application in Visual Studio 11.  Add two BlankPages to the application, naming the first Page1.xaml and the second (you guessed it) Page2.xaml. 

Find the Page name in each file and change them accordingly.  For example, on page 1, your code should look like this:

<TextBlock x:Name="pageTitle" 
   Text="Page 1" 
   Style="{StaticResource PageHeaderTextStyle}"/>

We need the ability to navigate from Page 1 to Page 2. For that, we’ll add a HyperLinkButton.  For purposes of formatting, we’ll put that control into a StackPanel:

 <StackPanel Grid.Row="1"
         Content="Click to go to page 2"

Go to page 2, where you’ve already fixed the name of the page, and add a TextBlock (again, within a StackPanel)

<StackPanel Grid.Row=”1″
    <TextBlock HorizontalAlignment=”Left” Name=”Message”  Text=”Hello World!”/>

Open Page1.xaml.cs and find the event handler for the HyperLinkButton.  Add the following line of code,

this.Frame.Navigate( typeof( Page2 ) );


Finally, open App.xaml.cs and set Page 1 as the start page.  To do so, locate OnLaunched() and substitute Page1 for BlankPage,



Run the application; Page 1 opens and offers you a link to Page 2. Page 2 displays your Hello World message.  Notice that Page 2 has a back button; that is actually on every  page, but Page 1 collapses the back button because CanGoBack is false (there is no page to go back to). 

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen Pluralsight & LinkedIn Learning courses. He was a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in Essentials, Windows 8. Bookmark the permalink.

4 Responses to Win 8 Page Navigation

  1. Pingback: Windows 8 Developer Links – 2012-04-18 | Dan Rigby

Comments are closed.