Setting start page of Windows Phone dynamically through code

I will start with saying , this post is small and sweet J I was working and come across a requirement to set start page of Windows Phone Application through code or dynamically.

Essentially this one line of code will set the start page of the application.


Say, you have a page called Page1.xaml and you want to set it as start page of application. Then you will have to set start page in App.Xaml.cs as below.

    private void Application_Launching(object sender, LaunchingEventArgs e)

                Uri nUri = new Uri("/Page1.xaml", UriKind.Relative);


Last thing you need to do is remove entry of default task from WMAppManifest.xml file. If you notice entry for default navigation page is empty.

      <DefaultTask  Name ="_default" NavigationPage=""/>
      <PrimaryToken TokenID="liveTilesToken" TaskName="_default">
          <BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>

This was all about setting the start page in Windows Phone application. I hope this quick post was useful. Thanks for reading Smile

2 responses to “Setting start page of Windows Phone dynamically through code”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at