Windows Phone 7 App Development

Archive for the ‘WP7’ Category

WP7 Portrait to Landscape Reorientation

leave a comment »

I thought I was pretty close to being done with the first version of Password Vault but have now discovered the joys of having to cope with reorienting the display from my chosen default Portrait view (where it looks good) to Landscape (which is not enabled by default) means that the display remains in Portrait mode when the device is rotated. The default setting in the XAML when the new page is Portrait is:

SupportedOrientations="Portrait" Orientation="Portrait"

Simply changing this to the following will at least allow the reorientation to occur and the screen will re-render when the orientation of the device changes:

SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"

However the display looks terrible! All my careful positioning of content to make it look good in Portrait mode results in a jumble of missing content and ugly layout in Landscape.

It is worth noticing that the there is an option to change the orientation when you right click on the page layout.  It simply flips the Orientation setting above.

It takes quite a bit of additional effort to rework the page so that it can handle the reorientation however in some respects this additional effort is quite rewarding as it can simplify the page.

I have chosen to implement a compromise solution which is to optimise the page layout for Portrait mode and then rework it to make a ‘best fit’ for Landscape.  I also wanted to avoid using code to manipulate XAML during the orient event.

There are two controls that can be used to help with the layout, StackPanel and WrapPanel (the WrapPanel is part of the Windows.Phone.Contols.Toolkit.dll that has to be referenced in the project and also included as a namespace in the XMAL.


The StackPanel has an Orientation property which will stack content controls either horizontally or vertically.

The WrapPanel is quite useful as the page can be designed so that it will work well in both orientations without having to resort to code to change the layout.

In this example a WrapPanel is used so that the prompt text and data entry look lay out nicely in both orientations.  I achieved this by setting the Width of the text box in the Portrait mode to the fixed size of the grid. 


When the orientation is changed to Landscape there is enough room to put the text box next to the prompt.


<toolkit:WrapPanel x:Name="StackPanelPassword" >
    <TextBlock Height="30" Name="textBlock2" Margin="12,0,0,0" Text="enter password:" Width="180" HorizontalAlignment="Left" />
    <TextBox Height="72" Name="textBoxPassword" Text="" Width="444" />

It has taken a few hours to sort out the layout for all the pages so that they can handle both orientations dynamically.  In doing so I have learnt quite a bit about the XAML and also tidied up the layout so that it is far less reliant on absolute positioning and now makes much greater use of the inherent capabilities of the layout containers.

See also:


Written by metadevblog

March 16, 2011 at 11:30 pm

Posted in WP7

Tagged with

WP7 Emulator

leave a comment »

I’ve been using the WP7 Emulator for a while now and its pretty useful.  It starts up quickly and on my dev machine is pretty responsive.  The Emulator is pretty limited in its functionality though – I wanted to test a send email code fragment but was unable to do so as it is not possible to set up email accounts.

A couple of useful bits of information though:

1. Press PgUp to use the dev machine keyboard for input – it’s much quicker and far more convenient than pecking around on the Emulator keyboard.

2. Download an unlocked copy of the Emulator for a richer UX.  However it takes around 2x to boot as the standard Emulator and still does not allow me to set up an email account; it does however let you test an application within the wider phone UI context.

I have both the official Emulator and the unlocked Emulator in the same directory.  I can then simply rename the one I want to use and its kicked off when I run my application in VS2010.

C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Emulation\Images

There are various blogs that explain how to unlock the Emulator but if all your after is the binary then I downloaded mine from here:

I was a bit dubious about the site to start with but it works (I don’t have an account and just took the time hit on it downloading slowly).

Written by metadevblog

March 15, 2011 at 8:36 am

Posted in WP7

Tagged with ,

Up and running…

leave a comment »

I have been working on a simple Windows Phone 7 application for a few weeks now in my spare time and have made really good progress. It is designed to solve an issue that I think bugs most people, having to remember the ever-increasing number of passwords in everyday use. I have a bad memory for this sort of thing at the best of times but I feel I am drowning in the damn things now.

Just about every web site I use requires a user name and a password to either see content or post information. There is very little consistency between sites and the password rules are somewhat arbitrary. Sometimes when I sign up to a site I don’t really want to use one of my ‘standard’ passwords as I don’t necessarily trust the site enough to compromise even my minimal unsecure passwords so end up choosing something else (which of course I immediately forget).

Logging into a site is a hit and miss affair and when you give up and request a new password you’re in the even worse position of having a random set of letters and numbers which you cut and paste into the web site. If you are like me you then don’t bother to change the password to something more memorable and the cycle repeats again…

So I created Password Vault to solve the problem. It’s quite simple, there is a visible prompt that gives a cue to the password and when this is clicked the password itself is displayed. As it is on your phone you can easily keep the information out of view of other people near by. When I started writing the application I was expecting it to have just a couple of screens but currently there are 8 distinct pages; a couple of which are overloaded to provide different functionality.

I still have the help to write and there are some graphics I need to generate but the basic application is just about complete now.  However as far as I can see the real work is just beginning!

David Middleton
Metamorphosis Developments Ltd.

Written by metadevblog

March 14, 2011 at 10:56 pm

Posted in Password Vault, WP7

Tagged with