Windows 7 Phone Development Tips - How To Set Page Orientation

One of the cool things about smartphones is that you can flip the view of your applications between landscape and portraint just by rotating your phone or device. Well, just because the hardware has the capability to flip these views does not mean that every application will adjust its view accordingly. When you develop a Windows 7 Phone application, you have to set the option of view(s) you are going to support.

Here are some notes from Microsoft's documentation of Windows 7 Phone API.

Windows Phone supports orientation changes, both portrait and landscape. If necessary, applications must be configured to support multiple orientations, and by default are set to only portrait. If a specified page on the application supports both landscape and portrait orientation, the user can initiate a change by physically rotating the device. There is no programmatic way to directly switch the orientation as the orientation property is set to read-only. The only method to accomplish this is to set the SupportedOrientations property to the desired orientation.

Note: The orientation portrait down, or upside down, is not supported in Windows Phone. Applications that need to use this feature can use the device accelerometer to change the UI; however, the chrome will remain in the normal portrait mode.

The page has an Orientation property and a SupportedOrientations property. If the application navigates to a page where the SupportedOrientations property does not include the current orientation, it will initiate a device orientation change to the specified orientation.

How to set orientation of Windows 7 Phone Application

As the documentation says that you have to set SupportedOrientation on the page. Current beta release of tools do not seem to allow to set this property from designer. So you can set this from the code itself. Following code snippets show how you can set SupportedOrientations property of a page.


public DetailsPage()
{
 InitializeComponent();
 SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
}

comments powered by Disqus

Search

Social

Weather

4.9 °C / 40.8 °F

weather conditions Clear

Monthly Posts

Blog Tags