Windows Phone Application Tip in Blend 4

Tue, Mar 23, 2010

Silverlight, Tutorials

This is a tip for developers using Blend 4 to create Windows Phone Applications. By default it seems that the ability to rotate the emulator and it contents is not set. A bit of code is necessary to have the contents of the application rotate properly with the emulator.

Note: In Visual Studio the code is included, this is a Blend 4 specific issue.

Default behavior
phone-wrong

After applying code
phone-good
C# code – Add line 21 SupportedOrientations =

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace OrientationTest
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
			SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
        }
    }
}
, ,

Leave a Reply

You must be logged in to post a comment.