When we develop an application for Windows Phone 7. One of the problem that a developer will face at the most is the circular navigation. On the phone, the navigation service handle the stack used by the back button. So each time we call the method Navigate of the NavigationService, a new entry is stored in the stack. On the other side there are some rules that a developer must follow to pass the certification on the Marketplace:
- circular navigation is not allowed
- the back button on the home page must exit the application.
There is some times that the scenarios doesn’t fit the rules for the Marketplace. So we end up more often with a circular navigation. Also which doesn’t help, it’s that we don’t have access to modify the navigation stack. This issue probably occurred very often in the certification process. First because, the developer did look at the Requirement documentation before creating his application. And second, because there is some times that the limitation doesn’t give us much choice.
(Image taken from the Windows Phone team blog)
So Microsoft listen and provide us with a solution. I’m glad because i had to use it in one of our application recently. The solution is pretty simple, we have to add a class in our application. Instantiate that class in the App class (App.xaml.cs). After what, we continue to handle the navigation as usual, but if we forgot to handle the back navigation or we face a scenario where we cannot handle the back navigation properly, we just have to navigate to the desired page (ex: navigate to the home page). At that time, if the class identify a circular navigation it will automatically handle the back navigation for us until we end up to the specified page.
But don’t be to lazy, and don’t rely on that mechanism. You should be aware of the Marketplace requirement first and follow them. But if in a specific case you don’t have a choice then you have a solution.
Get the code:
Get more information about the non-linear navigation:
I hope this will help you.