【问题标题】:SupportedOrientations unavailable in XAML of windows phone 8.1 app?Windows Phone 8.1 应用程序的 XAML 中支持的方向不可用?
【发布时间】:2014-06-23 19:58:55
【问题描述】:

Windows Phone 8.1 应用程序中的等效项是什么。当我创建一个新的应用程序时,没有更多的电话:ApplicationPage

<phone:PhoneApplicationPage
...
...
SupportedOrientations="Landscape" Orientation="LandscapeLeft"
shell:SystemTray.IsVisible="False">

【问题讨论】:

    标签: xaml windows-phone-8 windows-phone-8.1


    【解决方案1】:

    您可以通过代码强制任何页面的方向,在 this.InitializeComponent() 之后编写:

    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
    

    DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped;
    

    DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
    

    【讨论】:

    • 这是一种方法,但它会锁定整个应用程序的旋转。如果只锁定一页 AutoRotationPreferences 必须在 OnNavigatedFrom 中重置。
    • @JürgenBayer 它对我不起作用。方向未锁定:(
    【解决方案2】:

    是的,在 windows phone 8.1 中,我们不能在页面的 XAML 中设置supportedOrientations。我们只能在Package.appxmanifest中设置App的supportedOrientations。

    【讨论】:

    • 在将 Windows Phone Silverlight 移植到 Windows Phone 8.1 WinRT 时,微软刚刚忘记了一些事情。我们只能锁定整个应用程序,而不是单个页面。太好了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-06
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多