Reputation: 981
Irrespective of the orientation of device my app should run in portrait mode only.
Every page except only one page should run on the landscape.
How can I achieve this?
I tried below things:
On manifest file, I have checked supported rotation to "portrait" only. And written below code on the page I need to show in a landscape,
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape | DisplayOrientations.LandscapeFlipped;
}
But when run with simulator, it works in both portrait and landscape mode. What is the reason for it?
I have to rotate the simulator to 90 degree for seeing the app in portrait mode.
Upvotes: 1
Views: 805
Reputation: 8591
If you check the DisplayOrientations Enum document, you could see the remark shows:
Applications typically use this property to translate the reading of an accelerometer or to translate the physical button events in accordance with the current screen rotation.
It means that it has no effect on simulator. Besides, Auto-rotation also will be turned on by the user.
Please see the similar thread for more details:How to enable only landscape mode in a UWP app?
Upvotes: 0