Samuel LIOULT
Samuel LIOULT

Reputation: 624

Is it possible to lock orientation by device family in UWP app?

I would like to lock screen orientation to portrait only for mobile family. If I check only portrait in app manifest, it works: screen is locked in portrait orientation for mobile, but I think it is the same for tablets (Actually, I haven't tablet device for testing).

Upvotes: 1

Views: 763

Answers (1)

DotNetRussell
DotNetRussell

Reputation: 9857

According to this SO answer UWP C# Disable Orientation Change Animation

You need to set your screen orientation in your OnNavigatedTo override.

protected override void OnNavigatedTo(NavigationEventArgs e)
{
      if(/*on phone*/)
      {
        DisplayInformation.AutoRotationPreferences = DisplayOrientation.//Your Enum Value
      }
}

Here is a list of the DisplayOrientations off of the MSDN documentation

enter image description here

Upvotes: 4

Related Questions