Setting start page of Windows Phone dynamically through code

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

 var navTo = new Uri("/Views/MainPage.xaml", UriKind.RelativeOrAbsolute);
            ((App)Current).RootFrame.Navigate(navTo);

 Then you will have to set start page in App.Xaml.cs as below.

 private void Application_Launching(object sender, LaunchingEventArgs e)
{

}

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.

  <Tasks>
    <DefaultTask  Name ="_default" NavigationPage=""/>
  </Tasks>
  <Tokens>
    <PrimaryToken TokenID="liveTilesToken" TaskName="_default">
      <TemplateType5>
        <BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
        <Count>0</Count>
        <Title>liveTiles</Title>
      </TemplateType5>
    </PrimaryToken>
  </Tokens>

 

posted @ 2013-12-12 05:55  MinieGoGo  阅读(160)  评论(0编辑  收藏  举报