[英]Set start page in Windows Phone 8.1 universal app
我需要根据登录用户的身份更改应用程序中的开始页面。 在Silverlight 8.1版本中,我要做的就是删除清单文件和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.1universal应用程序中达到此目的?
编辑:找到重复的更改Windows Phone 8.1应用程序的默认启动页面 ,抱歉
在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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.