How to set Supported orientations property in Windows Phone 8.1

后端 未结 1 1830
天命终不由人
天命终不由人 2020-12-17 18:06

I wrote an application for WP 8 some time ago, I\'m currently working on updating it for WP 8.1.

My XAML and C#-skills have improved a lot since the initial launch,

相关标签:
1条回答
  • 2020-12-17 18:45

    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;
    

    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);
    }
    

    Read more about DisplayInformation.AutoRotationPreferences here.

    0 讨论(0)
提交回复
热议问题