When you create a new Modern UI(Metro) Windows 8 Project in Visual Studio , a default start page MainPage.xaml will be created automatically along with other necessary files needed for running the Windows 8 App.
How to change the Start page of the Windows 8 App in Visual Studio 2012 ?
If you want to change the default start page of the Windows 8 App from MainPage.xaml to another file for example (firstpage.xaml) , you can do that by following the below steps.
The App.xaml.cs has the Onlaunched event where the initial start page is defined . By Default , the MainPage is included .
You can create a new blank xaml page and replace “MainPage” with the newly create page name . For example , if your new pagename is firstpage.xaml , then replace MainPage with the firstpage like the way shown in the below sourcecode sample.
// Invoked when the application is launched normally by the end user. Other entry points // will be used when the application is launched to open a specific file, to display // search results, and so forth. //Details about the launch request and process. protected override void OnLaunched(LaunchActivatedEventArgs args) { // Do not repeat app initialization when already running, just ensure that // the window is active if (args.PreviousExecutionState == ApplicationExecutionState.Running) { Window.Current.Activate(); return; } if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Create a Frame to act navigation context and navigate to the first page var rootFrame = new Frame(); if (!rootFrame.Navigate(typeof(firstpage))) { throw new Exception("Failed to create initial page"); } // Place the frame in the current Window and ensure that it is active Window.Current.Content = rootFrame; Window.Current.Activate(); }
Now , run the application . You should see the Application running with the new start page in the Emulator now 🙂