How To Create More Pages In UWP App

Requirements

Visual Studio 2015 or higher version with Windows SDK.

Step 1: Open Visual Studio 2015. Go to File and go to New. Subsequently go to project.

File→New→Project

Project

Step 2: We can choose Visual C# and select Windows. Select the universal and next select the Blank App (Universal Windows).

Visual C#→Windows→universal→Blank App(Universal Windows)

Blank App

Step 3: Choose the target and the minimum platform version, which your Universal Windows Application will support.

application

Step 4: Open Mainpage.XAML. Add the following codes, given below:

XAML

The design page is given below:

design

design

Step 5: Open Mainpage.cs file. Add the codes, given below:

  1. namespace morepages   
  2. {  
  3.     /// <summary>  
  4.     /// An empty page that can be used on its own or navigated to within a Frame.  
  5.     /// </summary>  
  6.     public sealed partial class MainPage: Page   
  7.     {  
  8.         public MainPage() {  
  9.             this.InitializeComponent();  
  10.         }  
  11.         private void button_Click(object sender, RoutedEventArgs e) {}  
  12.         private void button1_Click(object sender, RoutedEventArgs e) {  
  13.             this.Frame.Navigate(typeof(BlankPage2));  
  14.         }  
  15.         private void button2_Click(object sender, RoutedEventArgs e) {  
  16.             this.Frame.Navigate(typeof(BlankPage3));  
  17.         }  
  18.     }  
  19. }  
In BlankPage2.cs file, add the codes, given below:
  1. namespace morepages {  
  2.     /// <summary>  
  3.     /// An empty page that can be used on its own or navigated to within a Frame.  
  4.     /// </summary>  
  5.     public sealed partial class BlankPage2: Page {  
  6.         public BlankPage2() {  
  7.             this.InitializeComponent();  
  8.         }  
  9.         private void button_Click(object sender, RoutedEventArgs e) {  
  10.             this.Frame.Navigate(typeof(MainPage));  
  11.         }  
  12.     }  
  13. }  
In BlankPage3.cs file, add the codes, given below:
  1. namespace morepages   
  2. {  
  3.     /// <summary>  
  4.     /// An empty page that can be used on its own or navigated to within a Frame.  
  5.     /// </summary>  
  6.     public sealed partial class BlankPage3: Page {  
  7.         public BlankPage3() {  
  8.             this.InitializeComponent();  
  9.         }  
  10.         private void button_Click(object sender, RoutedEventArgs e) {  
  11.             this.Frame.Navigate(typeof(MainPage));  
  12.         }  
  13.     }  
  14. }  
design

design

Step 6: You can run the project.

project

Step 7: You can see the output.

output

output

output

 

Recommended Ebook

Printing in C# Made Easy

Download Now!
Similar Articles