在 Windows Phone 8.1 通用应用中设置起始页 [英] Set start page in Windows Phone 8.1 universal app

查看:28
本文介绍了在 Windows Phone 8.1 通用应用中设置起始页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据登录用户与否来更改我的应用程序中的起始页.在 Silverlight 8.1 版本中,我需要做的就是删除清单文件和 App.xaml.cs 中的起始页:

I need to change start page in my app depending on logged user or not. In Silverlight 8.1 version all what I need to do is delete starting page in manifest file and in 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 通用应用中实现这一目标?

But in universal version I can't figure out how can I do it. What I need to do to achive this in WP 8.1universal app?

发现重复的 更改 windows phone 8.1 应用程序的默认启动页面,对不起

推荐答案

在App.xaml.cs中寻找

In App.xaml.cs look for

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    // ...

    // launch codes
    // insert here

    // Ensure the current window is active
    Window.Current.Activate();
}

我的启动代码会检测它们是否在电话上,所以我有一个起始页面每个平台不同

My launch code detects to see if they're on the Phone or not, so I have a starting page that is different for each platform

#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

这篇关于在 Windows Phone 8.1 通用应用中设置起始页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆