开发者

Why would I want to exit my silverlight Phone App

This is with reference to Windows Phone 7 close application

What if I have Page-A -> Page-B (i.e. Page-A allowijg navigation to Page-B) On Page-B, I have certain controls which take me to Page-C, page-D, Page-E, Page-F etc

If I am on Page-F, On pressing the back-key I want the user to reach Page-A (So, I override the OnBackKeyPressed). Now when On Page-A, if the user presses back-Key again, he is again taken to Page-B

So, I cannot exit the application when the user presses back key on Page-A and he is stuck between Page-A and Page-B while pressing back key

This is not consistent user expereince.

From the discussion, I understand that there is no (correct) way in silverlight to exit the application. So, Am I designing the application in an incorrect manner where I have lots of sub pages to show but I开发者_开发百科 would want the user to reach one of main pages by overriding the back key.


One thing you can do is instead of overriding the OnBackKeyPressed on Page F, override the OnNavigatedTo method on Page B to go one more page through the backstack to Page A. That way you will move your way up the stack more naturally. As you discovered, if you override the back key once to reroute someone, there is a good chance you will have to do it every time.

The only problem with this solution is that the WP7 does not have a easy way to know where you just came from. What I do is that every time I go to a new page, I cache the URI of the page I'm leaving.


Take a look at the Non-linear Navigation Service; it is meant to solve issues with circular navigation similar to what you seem to be having.

Without knowing the details of what you're trying to achieve it is hard to suggest an alternative, but maybe you should look into the design of your app to see if the navigation from page F to page A on back key press can be avoided.

Posting details of why you feel this is necessary may allow others to suggest alternate implementations.


If I understand you correctly your running into an issue with circular navigation. In other words you want the app to exit when you get to "Page-A". In that case you should definetly check out this recipe from Microsoft for working with circular navigation:

Solving Circular Navigation

Another method to use would be to use popups instead of creating new pages for the user to navigate to, that way you don't have to worry about handling the back stack.

Check out this Creating a custom popup in WP7.

Let me know if this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜