我想知道如何表示应用程序是第一次启动还是之前已经启动过。我想这样做的原因是在使用应用程序之前显示一条非常简短的信息性消息,而每隔一次启动应用程序时什么都没有显示。我会在 App.xaml.cs 中放置如下内容吗
var settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("WasLaunched"))
{
MessageBox.Show("First time to launch");
settings.Add("WasLaunched", true);
}
如果(!settings.Contains("WasLaunched")
导航到“第一个启动页面”而不是“主页”?有人可以向我指出有关此实现的任何好的参考吗?
编辑**
我将WMAppManifest.xml
默认页面更改为LaunchPage.xaml
<DefaultTask Name="_default" NavigationPage="LaunchPage.xaml" />
并创建了我的 UriMapper 类
public class LoginUriMapper : UriMapperBase
{
public override Uri MapUri(Uri uri)
{
if (uri.OriginalString == "/LaunchPage.xaml")
{
if (Settings.FirstLoad.Value == true)
{
//Navigate to Welcome Page with quick first time user info
uri = new Uri("/Views/WelcomePage.xaml", UriKind.Relative);
}
else
{
///Navigate to the actual Main Page
uri = new Uri("/MainPage.xaml", UriKind.Relative);
}
}
return uri;
}
}
但是我如何相应地更改 App.xaml.cs
private void Application_Launching(object sender, LaunchingEventArgs e)
{
//how to check and navigate to correct page for this specific method?
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
//how to check and navigate to correct page for this specific method?
}