I would recommend using a custom UriMapper. This allows you to not have to worry about your main page navigating to the login page and then having to manage the navigation stack.
You can read details about this approach here.
To accomplish this, modify the DefaultTask element in the WMAppManifest to navigate to a fake page
<DefaultTask Name="_default" NavigationPage="LaunchPage.xaml" />
Then create a UriMapper class
public class LoginUriMapper : UriMapperBase
{
public override Uri MapUri(Uri uri)
{
if (uri.OriginalString == "/LaunchPage.xaml")
{
// Determine for yourself how to store login info, AppSettings (IsoStore) is a good choice)
if (NeedsLoginInfo)
{
uri = new Uri("/LoginPage.xaml", UriKind.Relative);
}
else
{
uri = new Uri("/MainPage.xaml", UriKind.Relative);
}
}
return uri;
}
}
And last, set the mapper for your application in the Application_Launching event
private void Application_Launching(object sender, LaunchingEventArgs e)
{
RootFrame.UriMapper = new LoginUriMapper();
// You should also handle logging in if you already have info
// Determine for yourself how to store login info, AppSettings (IsoStore) is a good choice)
if (NeedsLoginInfo == false)
{
LoginObject.Login();
}
}
AND in the Application_Activated event IF the app is tombstoned
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (e.IsApplicationInstancePreserved == false)
{
RootFrame.UriMapper = new LoginUriMapper();
}
}