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);
((App)Application.Current).RootFrame.Navigate(nUri);
}
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>
This was all about setting the start page in Windows Phone application. I hope this quick post was useful. Thanks for reading ![]()
Discussion
Trackbacks/Pingbacks
Pingback: Monthly Report September 2011: Total Posts 28 « debug mode…… - October 1, 2011