Orientation

0
108

As shown in the preceding chapter, Windows phones support three orientations:

  • Portrait (vertical, with the screen above the hardware buttons)
  • Landscape Left (horizontal, with the screen to the left of the hardware buttons)
  • Landscape Right (horizontal, with the screen to the right of the hardware buttons)

To support orientations other than portrait, you can change the value of a page’s SupportedOrientations property to Landscape to only support the two landscape orientations, or to PortraitOrLandscape to support all three. You cannot choose to support only one of the landscape orientations; if your app works with one of the landscape orientations then it must work for both of them. Therefore, do not assume which side of the screen the application bar resides for a landscape page.

When you set SupportedOrientations to PortraitOrLandscape, the page automatically rotates to the proper orientation at the appropriate times (based on the angle the user holds their phone and whether a hardware keyboard is activated). This rotation is instant; your content is not animated. System-provided components, such as the status bar, application bar, message boxes and other notifications, adjust automatically as well, but with animations.

If you wish to perform a custom action when the orientation changes, such as a fullscreen animation or custom rearranging of elements, you can leverage a page’s OrientationChanged event.