在 WP7 应用程序的首页上调用 NavigationService.GoBack() 失败
我在使用 Windows Phone (7.1/Mango) 应用程序时遇到一个奇怪的问题。
我的理解是,如果在应用程序的初始页面上调用 NavigationService.GoBack()
,那么应用程序应该退出。当用户按下手机的后退按钮时会发生这种情况,但如果有具有相同功能的 UI 按钮,则不会发生这种情况(因为 NavigationServive.CanGoBack
返回 false
)。
这是故意的还是我遗漏了什么?我没有乱搞重定向初始导航或类似的事情,所以我无法解释这种功能差异。
我知道答案很简单“没有 UI 后退按钮”,这是非常正确的,但有人知道为什么会发生这种情况吗?
提前致谢!
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 account 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这是因为导航服务的“范围”仅限于您的应用程序。这使您可以更多地推断出用户如何使用您的应用程序。
例如,如果 CanGoBack 为 false,则这是用户正在访问的第一个页面。如果您使用应用程序的深层链接(来自提醒或 Toast 消息),这非常有用,因为您可能需要对深层链接采取不同的操作,而不是正常的页面导航。
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.