I want to set a start page in my windows phone 8 app programmatically after checking some data in config. Which event I can use to do the same?
Thanx in advance.
I used Application_Launching for same task. Something like this:
private void Application_Launching(object sender, LaunchingEventArgs e) { RootFrame.Navigated += RootFrame_Navigated; var logined = Singleton.Instance.User.Load(); var navigatingUri = logined ? "/View/PageMainPanorama.xaml" : "/View/Account/PageLoginRegister.xaml"; ((App)Current).RootFrame.Navigate(new Uri(navigatingUri, UriKind.Relative)); }
The first step is to remove the default page that us set by default in the manifest file (WMAppManifest.xml) in apps created from the standard templates.
Simply remove NavigationPage="MainPage.xaml" from the code below.
<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
</Tasks>
The start page is specified in InitializePhoneApplication() by calling RootFrame.Navigate() (in App.xaml.cs) .Like example below
private void InitializePhoneApplication()
{
if (phoneApplicationInitialized)
return;
// Create the frame but don't set it as RootVisual yet; this allows the splash
// screen to remain active until the application is ready to render.
RootFrame = new PhoneApplicationFrame();
RootFrame.Navigated += CompleteInitializePhoneApplication;
// Handle navigation failures
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
// Handle reset requests for clearing the backstack
RootFrame.Navigated += CheckForResetNavigation;
// Ensure we don't initialize again
phoneApplicationInitialized = true;
Uri uri;
if (IsolatedStorageSettings.ApplicationSettings.Contains("islogin"))
{
if (!(Convert.ToString(IsolatedStorageSettings.ApplicationSettings["islogin"]).ToLower() == "yes"))
{
RootFrame.Navigate(new Uri("/LoginScreen.xaml", UriKind.RelativeOrAbsolute));
}
else
{
RootFrame.Navigate(new Uri("/HomeScreen.xaml", UriKind.RelativeOrAbsolute));
}
}
else
{
RootFrame.Navigate(new Uri("/LoginScreen.xaml", UriKind.RelativeOrAbsolute));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With