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>
上一篇:关于信号量与线程互斥锁的区别与实现


下一篇:批量kill java进程方法-引出子shell和反引用