I am wondering how to signal whether an appication is launched for the very first time, or has already been launched before. The reason I want to do this is to show a very s
You'd better to use the power of UriMapper
Here you can find a good article.
The core idea is:
You should define an empty page (EntryPage.xaml
) and set it as a default page of your app.
Then in your custom UriMapper
you overload the MapUri
method.
public class YourUriMapper : UriMapperBase
{
public override Uri MapUri(Uri uri)
{
if (uri.OriginalString == "/EntryPage.xaml")
{
var settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("WasLaunched"))
{
uri = new Uri("/FirstRunInfoPage.xaml", UriKind.Relative);
}
else
{
uri = new Uri("/MainPage.xaml", UriKind.Relative);
}
}
return uri;
}
}
Then on app initialization you should define which UriMapper
to use:
private void Application_Launching(object sender, LaunchingEventArgs e)
{
RootFrame.UriMapper = new YourUriMapper();
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (e.IsApplicationInstancePreserved == false)
{
// tombstoned! Need to restore state
RootFrame.UriMapper = new YourUriMapper();
}
}