UWP C# Disable Orientation Change Animation

大城市里の小女人 提交于 2019-12-04 04:26:45

问题


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


回答1:


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!




回答2:


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



来源:https://stackoverflow.com/questions/35663676/uwp-c-sharp-disable-orientation-change-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!