Over a million developers have joined DZone.

Page Orientation in Windows Phone 7

DZone's Guide to

Page Orientation in Windows Phone 7

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

In this short tutorial I will show how to operate with Page Orientation in Windows Phone 7 applications.

Additional Information

Page Orientation

Each XAML page in a Windows Phone 7 application is able to support three modes of page orientation: Portrait, Landscape(left) and Landscape(right). To specify a page orientation you have to use SupportedPageOrientation Enumeration. Bellow are three images showing each of page orientation modes.

  • Portrait

  • Landscape (left)

  • Landscape (right)

To switch between orientations in emulator you can use the buttons shown on image bellow. Buttons appear when you hover your mouse over the emulator window.

Supported Page Orientations

You can specify supported Page Orientations for each page in XAML markup or programmatically (in code). To enter page orientations in XAML you have to modify the “SupportedOrientations” and, probably, “Orientation” attribute in phone:PhoneApplicationPage element (check image bellow). SupportedOrientations uses SupportedPageOrientation enumeration and Orientation is a default Orientation for the page. For example if your application is going to use Landscape as SupportedPageOrientation then make sure the Orientation attribute is set to Landscape also otherwise the page will look badly in emulator and phone.

To specify page orientations manually in code you need to add one of the following lines to your page code (for example to page constructor)

// for portait only orientation
SupportedOrientations = SupportedPageOrientation.Portrait;
 // for landscape only orientation
SupportedOrientations = SupportedPageOrientation.Landscape;
// for both orientations
SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;

Page Orientations change event

As developer, you have an opportunity to override the page orientation change event to add some extra functionality to it (for example to change size of some page elements). To do so you have to override OnOrientationChanged method:

protected override void OnOrientationChanged(OrientationChangedEventArgs e)
    // add some extra functionality here


Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda


Published at DZone with permission of Jevgeni Tšaikin. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}