我需要根据登录用户更改我的应用程序中的起始页。在 Silverlight 8.1 版本中,我需要做的就是删除 list 文件和 App.xaml.cs 中的起始页:
private void Application_Launching(object sender, LaunchingEventArgs e)
{
Uri uriMain = new Uri("/PivotPage.xaml", UriKind.Relative);
Uri uriLogin = new Uri("/MainPage.xaml", UriKind.Relative);
var settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("user_id"))
{
RootFrame.Navigate(uriLogin);
}
else
{
RootFrame.Navigate(uriMain);
}
}
但是在通用版本中我不知道该怎么做。我需要做什么才能在 WP 8.1 通用应用程序中实现这一目标?
编辑: 找到重复项 Change default startup page for windows phone 8.1 app , 对不起
请您参考如下方法:
在 App.xaml.cs 中寻找
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
// ...
// launch codes
// insert here
// Ensure the current window is active
Window.Current.Activate();
}
我的启动代码会检测他们是否在电话上,所以我有一个起始页是 每个平台不同
#if WINDOWS_PHONE_APP
if (!rootFrame.Navigate(typeof(PhonePage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
#endif
#if WINDOWS_APP
if (!rootFrame.Navigate(typeof(DesktopPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
#endif
