Logo
HOW TO
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows Phone

Windows Phone 8 : Orientation and the PhoneApplicationPage Class - Setting Page Orientation at Runtime

8/1/2014 4:37:02 AM

The Orientation property of the PhoneApplicationPage class cannot be assigned at runtime. Another approach is required to change the page orientation. For this turn to the SupportedOrientations property, which is assignable at runtime.

To recap, the SupportedOrientations property defines the allowed orientation or orientations of the page, which can be Portrait, Landscape, or PortraitOrLandscape.

Setting the SupportedOrientations property to the desired orientation forces the page to be shown in that orientation. For example, if the page is being viewed in portrait orientation, and you want to change the page orientation to landscape, you can set the SupportedOrientations to Landscape, thereby restricting the allowed orientation to landscape and forcing the frame to change the orientation to landscape.

This technique is demonstrated in the OrientationView page in the downloadable sample code (see Figure 1).

Image

FIGURE 1 Forcing the orientation of a page.

The OrientationView class’s Switch Supported Orientation button alternates between the three SupportedPageOrientation values. This is performed in the button’s Tap event handler, demonstrating how the orientation can be forcibly set by restricting the orientation, as shown in the following excerpt:

void Button_Tap(object sender, GestureEventArgs e)
{
    switch (SupportedOrientations)
    {
        case SupportedPageOrientation.Landscape:
            SupportedOrientations = SupportedPageOrientation.Portrait;
            break;
        case SupportedPageOrientation.Portrait:
            SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
            break;
        default:
            SupportedOrientations = SupportedPageOrientation.Landscape;
            break;
    }
}

Other -----------------
- Windows Phone 8 : Orientation and the PhoneApplicationPage Class - PhoneApplicationPage Orientation Property
- Windows Phone 8 : The Multimedia Experience - Xbox Music Pass (part 2) - Playing Music from the Xbox Music Pass
- Windows Phone 8 : The Multimedia Experience - Xbox Music Pass (part 1) - Connecting Your Phone to Xbox Music Pass
- Windows Phone 8 : Working with File Explorer (part 3) - Copying Multimedia Content to Your PC
- Windows Phone 8 : Working with File Explorer (part 2) - Removing Media from Your Phone
- Windows Phone 8 : Working with File Explorer (part 1) - Adding Media to Your Phone
- Windows Phone 8 : Orientation and the PhoneApplicationPage Class (part 5) - Animating the Entire Page When Orientation Changes
- Windows Phone 8 : Orientation and the PhoneApplicationPage Class (part 4) - Animating Page Elements When the Page Orientation Changes
- Windows Phone 8 : Orientation and the PhoneApplicationPage Class (part 3) - Setting Page Orientation at Runtime
- Windows Phone 8 : Orientation and the PhoneApplicationPage Class (part 2) - PhoneApplicationPage Orientation Property
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox
 
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
Top 10
- Microsoft Excel : How to Use the VLookUp Function
- Fix and Tweak Graphics and Video (part 3) : How to Fix : My Screen Is Sluggish - Adjust Hardware Acceleration
- Fix and Tweak Graphics and Video (part 2) : How to Fix : Text on My Screen Is Too Small
- Fix and Tweak Graphics and Video (part 1) : How to Fix : Adjust the Resolution
- Windows Phone 8 Apps : Camera (part 4) - Adjusting Video Settings, Using the Video Light
- Windows Phone 8 Apps : Camera (part 3) - Using the Front Camera, Activating Video Mode
- Windows Phone 8 Apps : Camera (part 2) - Controlling the Camera’s Flash, Changing the Camera’s Behavior with Lenses
- Windows Phone 8 Apps : Camera (part 1) - Adjusting Photo Settings
- MDT's Client Wizard : Package Properties
- MDT's Client Wizard : Driver Properties
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro