开发者

Calling NavigationService.GoBack() fails on the first page of a WP7 app

开发者 https://www.devze.com 2023-04-11 22:15 出处:网络
I have a strange problem with a Windows Phone (7.1/Mango) app. My understanding is if NavigationService.GoBack() is called on the initial page of an app, then the app should exit. This happens when t

I have a strange problem with a Windows Phone (7.1/Mango) app.

My understanding is if NavigationService.GoBack() is called on the initial page of an app, then the app should exit. This happens when the user presses the phone's back button, but it does not happen if there's a UI button with the same functionality (because NavigationServive.CanGoBack returns false).

Is this intentional or am I missing something? I haven't messed around with redirecting the initial navigation or anything like that, so I can't ac开发者_StackOverflowcount for this difference in functionality.

I know the answer is simply "don't have a UI back button", which is very true, but does anyone know why this happens?

Thanks in advance!


I believe this is because the navigation service is "scoped" to your application. This allows you to deduce a bit more about how the user is using your app.

For instance if CanGoBack is false then this is the first page the user is visiting. This is useful if you're using deep links into your app (from reminders or toast messages) because you may need to act differently on the deep link as opposed to a normal navigation to the page.

0

精彩评论

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

关注公众号