Geeks With Blogs
Ilya Verbitskiy Thoughts and links about computer programming


Finally I have had a chance to start developing Windows 8 applications. I have started with C#/XAML applications. The reason is obvious: I had done a lot of WPF development in the last three years. I have been surprised how easy it is to start building the applications. I have started with Professional Windows 8 Programming: Application Development with C# and XAML and write the code.

Today I’d like to show you one trick which is not obvious for Windows 8 beginners. How can you change Windows 8 Apps’ Start Page?

Let’s create a blank Windows Store Application and show a “Hello Windows 8!” on its Start Screen. Start Screen is MainPage.xaml by default. Open it and add this code.

  1: <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
  2:         <TextBlock Text="Hello Windows 8!"
  3:                    FontSize="40"
  4:                    VerticalAlignment="Center"
  5:                    HorizontalAlignment="Center" />
  6: </Grid>


Let’s add another page to the application, e.g. NewStartup.xaml, and show “Hello World!” message there, like this:

  1: <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
  2:         <TextBlock Text="Hello World!"
  3:                    FontSize="40"
  4:                    VerticalAlignment="Center"
  5:                    HorizontalAlignment="Center" />
  6: </Grid>


Now we can start with the tricky part. All Windows Store Applications have a manifest file Package.appxmanifest. This is the place where you can set you app’s logos, startup image, default language, etc. You can also specify you application capabilities, e.g. access to a web-cam or Internet. But this is another story.


You can see Entry point value on the screen. This class the class which runs when the app is activated. But it is not the same as you app’s Start Page. Let’s take a look what we have there.

  1: using System;
  2: using System.Collections.Generic;
  3: using System.IO;
  4: using System.Linq;
  5: using Windows.ApplicationModel;
  6: using Windows.ApplicationModel.Activation;
  7: using Windows.Foundation;
  8: using Windows.Foundation.Collections;
  9: using Windows.UI.Xaml;
 10: using Windows.UI.Xaml.Controls;
 11: using Windows.UI.Xaml.Controls.Primitives;
 12: using Windows.UI.Xaml.Data;
 13: using Windows.UI.Xaml.Input;
 14: using Windows.UI.Xaml.Media;
 15: using Windows.UI.Xaml.Navigation;
 17: // The Blank Application template is documented at
 19: namespace Blog1
 20: {
 21:     /// <summary>
 22:     /// Provides application-specific behavior to supplement the default Application class.
 23:     /// </summary>
 24:     sealed partial class App : Application
 25:     {
 26:         /// <summary>
 27:         /// Initializes the singleton application object.  This is the first line of authored code
 28:         /// executed, and as such is the logical equivalent of main() or WinMain().
 29:         /// </summary>
 30:         public App()
 31:         {
 32:             this.InitializeComponent();
 33:             this.Suspending += OnSuspending;
 34:         }
 36:         /// <summary>
 37:         /// Invoked when the application is launched normally by the end user.  Other entry points
 38:         /// will be used when the application is launched to open a specific file, to display
 39:         /// search results, and so forth.
 40:         /// </summary>
 41:         /// <param name="args">Details about the launch request and process.</param>
 42:         protected override void OnLaunched(LaunchActivatedEventArgs args)
 43:         {
 44:             Frame rootFrame = Window.Current.Content as Frame;
 46:             // Do not repeat app initialization when the Window already has content,
 47:             // just ensure that the window is active
 48:             if (rootFrame == null)
 49:             {
 50:                 // Create a Frame to act as the navigation context and navigate to the first page
 51:                 rootFrame = new Frame();
 53:                 if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
 54:                 {
 55:                     //TODO: Load state from previously suspended application
 56:                 }
 58:                 // Place the frame in the current Window
 59:                 Window.Current.Content = rootFrame;
 60:             }
 62:             if (rootFrame.Content == null)
 63:             {
 64:                 // When the navigation stack isn't restored navigate to the first page,
 65:                 // configuring the new page by passing required information as a navigation
 66:                 // parameter
 67:                 if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
 68:                 {
 69:                     throw new Exception("Failed to create initial page");
 70:                 }
 71:             }
 72:             // Ensure the current window is active
 73:             Window.Current.Activate();
 74:         }
 76:         /// <summary>
 77:         /// Invoked when application execution is being suspended.  Application state is saved
 78:         /// without knowing whether the application will be terminated or resumed with the contents
 79:         /// of memory still intact.
 80:         /// </summary>
 81:         /// <param name="sender">The source of the suspend request.</param>
 82:         /// <param name="e">Details about the suspend request.</param>
 83:         private void OnSuspending(object sender, SuspendingEventArgs e)
 84:         {
 85:             var deferral = e.SuspendingOperation.GetDeferral();
 86:             //TODO: Save application state and stop any background activity
 87:             deferral.Complete();
 88:         }
 89:     }
 90: }

This code is automatically generated by Visual Studio 2012. the answer to our questions is in line 67.


Frame.Navigate method accepts you Start Page’s type and show it when you application has started. What you should do now if to change MainPage to NewStartup, save the file and run the application.

I had been skeptical about Windows 8 as a platform for applications development, but I changed my opinion now. It is great platform and it is really easy to start with. I hope I will have time to write my about my adventures in new Windows world in the future.

Posted on Monday, May 6, 2013 7:15 AM Windows Store | Back to top

Comments on this post: How to change Windows Store App’s Start Page?

# windows mobile development
Requesting Gravatar...
Thanks for sharing you valuable information. Rely it is very usefull for me to change my change Windows Store App’s Start Page.
Left by Udit Handa on May 15, 2013 9:04 AM

# re: How to change Windows Store App’s Start Page?
Requesting Gravatar...
I have a question ...
How did you open the file Blog1.App?
I can't find that file in the solution explorer, can you explain how can I open it.
Left by Mostafa on Jul 01, 2013 7:40 PM

# re: How to change Windows Store App’s Start Page?
Requesting Gravatar...

Open you solution, expand App.xaml and open App.xaml.cs. This is the file where you can set your entry point.

Left by Ilya on Jul 08, 2013 4:48 AM

# re: How to change Windows Store App’s Start Page?
Requesting Gravatar...
Hi ,
I am developing a windows 8 phone App, in which i have a registration page at the beginning which is my MainPage.xaml and later there is a page displaying a Long list Selector. Now , whenever a user opens the app for the first time (i.e installation) i want the MainPage.xaml to open but once the user has registered i want the startup page to be something else. How do i accomplish that?
Left by Queen on Mar 10, 2014 9:05 PM

# re: How to change Windows Store App’s Start Page?
Requesting Gravatar...

I'd load user settings and navigate to a particular class based on user registration flag.
Left by Ilya on Mar 11, 2014 6:48 AM

# re: How to change Windows Store App’s Start Page?
Requesting Gravatar...
This would indeed be a really helpful thing for a lot of people who are looking forward to some really nice changes towards the future. It is sure to help you to get through your work with ease like never before. clip on man buns
Left by Willam Turner on Jan 22, 2016 10:28 AM

Your comment:
 (will show your gravatar)

Copyright © Ilya Verbitskiy | Powered by: