清除导航服务中的后台堆栈
我正在浏览应用程序中的不同页面。登录后,我从导航开始的地方进入主页。在导航过程中,当我进入主页时,我想通过按 BackKey 转到登录页面,但我只能导航到之前导航过的页面。我可以重写 BackKeyPress 事件以导航到登录页面,但在 LoginPage 中我应该再次重写 Backkeypress,否则按下后键时登录页面和主页之间会出现循环。有没有办法清除导航历史记录?
I am navigating through different pages within my application. After I login, I come to home page from where the navigation starts. During navigation, when I come to homepage, I want to go to the login page by pressing BackKey but I can only navigate to previously navigated page. I could have overriden the BackKeyPress event to navigate to the Login Page but in LoginPage I should again override the Backkeypress otherwise there appears to be cycle between loginpage and homepage on backkey press. Is there anyway to clear the navigation history?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 NavigationService.RemoveBackEntry: http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.removebackentry%28v=VS.92%29.aspx
例如,删除堆栈中的所有条目:
Also, if you want to remove only the previous page after checking its URI:
You can use NavigationService.RemoveBackEntry: http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.removebackentry%28v=VS.92%29.aspx
For instance, to remove all entries from the stack:
Also, if you want to remove only the previous page after checking its URI:
虽然我知道最初的问题是针对 7 的,但在 Windows Phone 8.1 中,NavigationService 不再存在。
这是 Windows Phone 8.1 代码
While I know the original question was for 7, in Windows Phone 8.1 the NavigationService no longer exists.
Here is the Windows Phone 8.1 code