AbsoluteSith AbsoluteSith -4 years ago 209
C# Question

How to enable only landscape mode in a UWP app?

I have already specified in the manifest as Landscape and LandscapeFlipped, I know this is just a preference and on top of this I've added the below code in the App.xaml.cs OnLaunched. But yet when tested on a tablet the app goes back to portrait mode.

DisplayInformation.AutoRotationPreferences =
DisplayOrientations.Landscape | DisplayOrientations.LandscapeFlipped;

Also is there any alternative way I could test this in a simulator instead of an actual tablet/device?

Thanks in advance.

Answer Source

Since my comment helped you im going to add it as answer



[DllImport("user32.dll", EntryPoint = "#2507")]
extern static bool SetAutoRotation(bool bEnable);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download