如何设置支持方向属性的Windows Phone 8.1 [英] How to set Supported orientations property in Windows Phone 8.1
问题描述
我写了WP 8的应用程序前一段时间,我目前正在更新其用于WP 8.1。
I wrote an application for WP 8 some time ago, I'm currently working on updating it for WP 8.1.
我的XAML和C#-skills都提升了很多自首次推出,所以我决定从头开始重写它,以避免通过老挖,小白代码(是啊...它不漂亮)。
My XAML and C#-skills have improved a lot since the initial launch, so I decided to rewrite it from scratch in order to avoid digging through old, noob code (yeah... it isn't pretty).
一件事,我似乎无法左右我的头是如何处理启用和禁用的应用取向的变化。我已经找到了一种方法,使总的启用/与Package.appmanifest禁用。 。这并不完全符合我不过之后我
One thing that I can't seem to get my head around is how to deal with enabling and disabling orientation-changes for the app. I've found a way to make a total enable/disable with the "Package.appmanifest". That's not quite what I'm after however.
我只是写了这个在老版本我的应用程序页面的顶部:
I simply wrote this at the top of my app pages in the old version:
<phone:PhoneApplicationPage
SupportedOrientations="PortraitOrLandscape"
etc...
etc...
>
这适合我很好,因为有些网页干脆在纵向和横向模式没有工作。 (我花了比我关心记住试图使其工作......更多的时间),但它不会在8.1工作。
This suited me very well since some pages simply didn't work in both portrait and landscape mode. (I spent more time than I care to remember trying to make it work...) But it won't work in 8.1.
请问的某种灵魂的知识方法来设置每页所需的方向,支持的Windows Phone 8.1?
Would some kind soul know of a way to set desired orientation-support per page in Windows Phone 8.1?
推荐答案
您可以做到这一点,如果你想只是纵向
You could do this if you wanted just portrait
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
或者这样,如果你想纵向和横向
Or this if you wanted Portrait and Landscape
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait | DisplayOrientations.Landscape;
或者,如果你想只是景观及景观翻转
Or if you wanted just Landscape and Landscape Flipped
DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped | DisplayOrientations.Landscape;
等。每一页上,这样你就可以启用/取决于在页面上禁用方向和你打算如何使用它。你可以将其设置在例如的OnNavigatedTo事件处理程序。
etc. on every page, so you can enable/disable orientations depending on the page and how you intend to use it. You can set it in OnNavigatedTo event handler for example.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped | DisplayOrientations.Landscape;
this.navigationHelper.OnNavigatedTo(e);
}
了解更多的这里 DisplayInformation.AutoRotationPreferences。
Read more about DisplayInformation.AutoRotationPreferences here.
这篇关于如何设置支持方向属性的Windows Phone 8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!