Windows Phone 8.1应用程序的XAML中不支持SupportedOrientations?

ero*_*las 6 xaml windows-phone-8 windows-phone-8.1

在Windows Phone 8.1应用程序中,这相当于什么.当我创建一个新的应用程序时,没有更多的手机:ApplicationPage

<phone:PhoneApplicationPage
...
...
SupportedOrientations="Landscape" Orientation="LandscapeLeft"
shell:SystemTray.IsVisible="False">
Run Code Online (Sandbox Code Playgroud)

the*_*uts 8

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

DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
Run Code Online (Sandbox Code Playgroud)

要么

DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped;
Run Code Online (Sandbox Code Playgroud)

要么

DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
Run Code Online (Sandbox Code Playgroud)

  • 这是一种方法,但它锁定整个应用程序的旋转.如果只应锁定一个页面,则必须在OnNavigatedFrom中重置AutoRotationPreferences. (2认同)

Chr*_*hao 7

是的,在Windows Phone 8.1中,我们无法在页面的XAML中设置supportedOrientations.我们只能在Package.appxmanifest中设置App的supportedOrientations.