AZX
AZX

Reputation: 572

UWP C# Disable Orientation Change Animation

Is it possible to disable the 'screen rotating' animation that is executed when phone's rotation changes (from landscape to portrait or vice versa)?

Upvotes: 3

Views: 2810

Answers (2)

RicardoPons
RicardoPons

Reputation: 1353

you need to use DisplayInformation.AutoRotationPreferences = DisplayOrientations.LandscapeFlipped | DisplayOrientations.Landscape;

you need to set the orientation in OnNavigatedTo of you pages, you can enable or disable different orientations depending of your pages or your requirements.

Update: If you want to rotate the buttons like the Camera app with a smooth animation there are some ways to do:

1.- Using Gyrometer :

You need to create your own animation with storyboards moving rotation of the buttons in realtime according of the position of the device. you will need to do some calculations to determine if the device is in portrait or landscape mode and move the buttons in realtime like Nokia Camera.

I did this approach for Windows Phone 8 it's very hard but the final work It was very good! https://msdn.microsoft.com/library/windows/apps/br225718

2.- using OrientationChanged event

you need to listen the event OrientationChanged event and detest of the device is in portrait or landscape mode immediate you will need to execute some animations to your controls to be rotated you can do this approach using Blend and StoryBoards https://msdn.microsoft.com/en-us/library/windows/apps/windows.graphics.display.displayproperties.orientationchanged.aspx

Here is an example to create a easy animation to rotate an image

https://comentsys.wordpress.com/2015/05/06/windows-10-universal-windows-platform-image-rotate/

The big difference between the two options is in the first option you offer a nice experience in real time changing the controls depending of the orientation of the device with the second approach after the event is raised you will execute the animation.

Best regards

Please mark this answer if it's useful for you!

Upvotes: 4

Nghia Nguyen
Nghia Nguyen

Reputation: 2665

Go to package.appxmanifest on Application tab Supported rotations: Choose your Portrait or Landscape enter image description here

Upvotes: 4

Related Questions