【问题标题】:Set start page in Windows Phone 8.1 universal app在 Windows Phone 8.1 通用应用程序中设置起始页
【发布时间】:2014-11-05 19:00:47
【问题描述】:

我需要根据登录用户更改我的应用中的起始页。在 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.1 通用应用程序中实现这一目标?

编辑: 发现重复的Change default startup page for windows phone 8.1 app,抱歉

【问题讨论】:

    标签: c# windows-phone-8.1


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-07
      • 2016-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-07
      相关资源
      最近更新 更多