This week I attended a WP7 boot camp and was reminded that the phone has more than one orientation. The instructor did a Hello Phone application and should that the default behaviour is a single orientation, Portrait. She then went on to explain that with a bit of code, landscape can be supported. Actually, it is even easier than that. In the XAML is the keyword SupportedOrientations. Select the value for the keyword and hit a letter. Thanks to IntelliSense, Visual Studio will give you a choice of three options: Portrait, Landscape or PortraitOrLandscape. Just chosing the last option will allow you app to switch based on orientation. If you let XAML do the heavy lifting, that may be all you have to do. The screen will snap when the orientation is changed, but transitions are something you can easily add to the XAML. The key thing to remember is not to hard code widths, let XAML adjust the display as the width changes.
So with a little code behind and XAML you can do some fancy things with your app. Unfortunately, that is where a lot of developers stop.
Are you aware that there are three not two orientations and they can be detected in code? Actually, there should be four, but for some reason Microsoft decided not to implement it. So, in addition to Portrait, there are TWO landscape modes, Landscape Left and Landscape Right (or you could call them Landscape and Upside down Landscape). The missing one is Upside down Portrait, which I think would be interesting.
So, two landscapes, big deal. Built in to WP7 is an app that demonstrates one of the possibilities that this extra orientation can give, the Calculator. In portrait orientation, it is a simple calculator. Turn it to lanscape and you have a scientific calculator. turn it 180 degrees and now you have a programmer’s calculator. So in addition to changing the position of items in the layout as you rotate the phone, your app could provide a different experience depending on one of the three orientations. What about a skiing game when in Portrait, flying game when in landscape left and a swimming game when in landscape right? Of course, you will have to limit your game experience to being less than a 45 degree rotation of the phone if you want to stay on that layout, but then that could mean some interesting transitions.
John Marshall… Visio MVP Visio.MVPs.org