Damien
Damien

Reputation: 2901

How to know the Orientation of a Page before we had PageOrientation LandscapeRight/LandscapeLeft?

In Windows Phone 8.0 we had PageOrientation with LandscapeLeft, LandscapeRight and more. Now, we only have ApplicationView.GetForCurrentView().Orientation and DisplayProperties.CurrentOrientation, but both of these only tell me if my page is Horizontal or Vertical. Does anyone know how to reproduce the LandscapeLeft and LandscapeRight we had in Windows Phone 8?

When a user rotates the page of my application (Windows Phone 8.1 XAML) I need to know if he has rotated the application Clockwise or CounterClockwise anyone have a idea how I could do that?

Upvotes: 2

Views: 90

Answers (1)

Damien
Damien

Reputation: 2901

After looking I think I may have found a solution but it might not be the best solution:

Using

 DisplayProperties.OrientationChanged += Page_OrientationChanged;

We are able to see when the page is being rotated, then in this method we get the new orientation using DisplayProperties.CurrentOrientation:

 private void Page_OrientationChanged(object sender)
        {
            DisplayOrientations orientation = DisplayProperties.CurrentOrientation;

switch (orientation )
            {
                case DisplayOrientations.Landscape:
                    bla();
                    break;
                case DisplayOrientations.LandscapeFlipped:
                    blabla();
                    break;    
                case DisplayOrientations.Portrait:
                    MoreBla();
                    break;
                case DisplayOrientations.PortraitFlipped:
                    MoreBlaBla();
                    break;
            }
        }

Here we are able to know if the page has been rotated into Landscape, LandscapeFlipped, Portrait and or PortraitFlipped.

Upvotes: 3

Related Questions