Windows Phone 7: Jumping through the Back Stack

Having a Back Stack within your application is a mixed blessing. Whilst the navigation service will allow you to easily step the user from one page to the next, allowing the user to return to the previous page via the back key, it can often end up with applications that are 10 or more pages in length. If the user wants to exit the application, or to go back to the previous application they have to step through all the pages (Internet Explorer, one of Microsoft’s own applications, is probably the worst case I’ve seen of this and imho is a complete design failure).

The guidance for building applications for Windows Phone 7 essentially suggests caution in opening up a new page for every activity the user does. Rather than a new page for everything, you can simply adjust the content rendering in the current page. This leads to another discussion on what’s appropriate use of the Back Button.

This morning I had a conversation with Shane ( regarding an application where the user had to step through a wizard. At the end of the wizard they effectively want to remove the wizard pages (ie the steps in the wizard) from the Back Stack, returning them to the page that they were on before the wizard. My thoughts are that the Wizard should be a single page where each step is essentially just a different visual state. The Back Button could still be used within the page, allowing the user to still step through the steps in the wizard. When they have completed the wizard it would then close the page, returning them to the previous page.

If my suggestion isn’t an option, then there are two ways (that I can think of) to return to the initial page:

– Throw an exception (eg GoHomeException) which is trapped by the Application_UnhandledException method. This could then navigate back to the initial page

– Set a global flag (eg GoingHome) and then use GoBack to return to the previous page. Essentially each page in the wizard would look for the global flag, and if it is set to true then it would automatically call GoBack until the initial page is found.

Both of these strategies can be seen in the following example

Leave a comment