Change The Default Startup Page In UWP

When you are creating any new Universal Windows Application, Visual Studio defaults start the MainPage.xaml. Here we will have a look at how to change it to a custom page according to the user choice. 

Step 1: Open Visual Studio and add a new page to your project by right clicking your Project Add a New Item

 
Step 2: Add a new Blank Page. You can give your custom name for the App. Here I have given a name myNewPage  
 
 
Here for understanding I have changed the background color of my new page to light blue.
 
Step 3: Open the App.xaml.cs page and find the following code
  1. if (e.PrelaunchActivated == false)  
  2. {  
  3.     if (rootFrame.Content == null)  
  4.     {  
  5.         // When the navigation stack isn't restored navigate to the first page,  
  6.         // configuring the new page by passing required information as a navigation  
  7.         // parameter  
  8.         rootFrame.Navigate(typeof(MainPage), e.Arguments);  
  9.     }  
  10.     // Ensure the current window is active  
  11.     Window.Current.Activate();  
  12. }  
Step 4: Here change the MainPage to your new Page name
 
Step 5: Run and Test your Application 
 


Similar Articles