[UWP] [C#]在平板电脑和手机上设置特定方向 [英] [UWP] [C#] Set specific orientation on tablet and phone

查看:68
本文介绍了[UWP] [C#]在平板电脑和手机上设置特定方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果平板电脑或桌面仅使用横向,而在电话上仅使用纵向,则可以设置屏幕方向吗?如何应用?

Can I set the screen orientation if the tablet or desktop uses landscape orientation only, while on the phone using portrait orientation only? How to apply it?

推荐答案

Hello。

Hello.

Util WP8.1有PhoneApplicationPage控件的SupportedOrientations属性。但在UWP中并不存在这样的财产。为了实现你想要的你应该改变 

Util WP8.1 there was SupportedOrientations property for PhoneApplicationPage control. But in UWP there doesnn't exist such property. For achieve what you want you should change 

DisplayInformation.AutoRotationPreferences


 protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            switch (AnalyticsInfo.VersionInfo.DeviceFamily)
            {
                case "Windows.Mobile":
                    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
                    break;
                case "Windows.Desktop":
                    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
                    break;
            }
        }


这篇关于[UWP] [C#]在平板电脑和手机上设置特定方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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