Windows Phone后退按钮问题
我有一个有 2 个表单的应用程序,主表单和属性表单,当我单击导航到属性的按钮,然后单击后退按钮(硬件)时,我得到了我所期望的结果,我的应用程序返回到主表单,但是如果我应用属性并再次导航到主页并再次按后退按钮,我将返回到属性,如果我继续按后退,我可以返回到无限属性/主页,这很糟糕,因为主页已更改了其特性。
Good cases:
MainPage ---> properties --back--> MainPage (No properties were set)
MainPage ---> properties --set--> newMainPage
MainPage ---> properties --set--> MainPage --back--> closeApp
Bad cases:
MainPage ---> properties --set--> MainPage --back--> properties --back--> oldMainPage
MainPage ---> properties --set--> newMainPage ---> properties --set--> new_newMainPage --back--> properties --back--> oldMainPage --back--> properties --back--> old_oldMainPage
也许我可以删除导航缓存?我已经尝试过这个,但编译器告诉我它是只读的:
this.NavigationCacheMode = System.Windows.Navigation.NavigationCacheMode.Disabled;
我当前的导航代码是:
NavigationService.Navigate(new Uri("/Properties.xaml",UriKind.RelativeOrAbsolute));
and
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
I have an app that has 2 forms, the main form and a properties form, when I click the button that navigates into properties and then I click the back button (hardware) I get what I expect, my app returns to the main form, but if I apply the properties and navigate to the main page again and push the back button again I return to properties, and if I keep pushing back I can return to infinite properties/main page, which is bad because the main page has changed its properties.
Good cases:
MainPage ---> properties --back--> MainPage (No properties were set)
MainPage ---> properties --set--> newMainPage
MainPage ---> properties --set--> MainPage --back--> closeApp
Bad cases:
MainPage ---> properties --set--> MainPage --back--> properties --back--> oldMainPage
MainPage ---> properties --set--> newMainPage ---> properties --set--> new_newMainPage --back--> properties --back--> oldMainPage --back--> properties --back--> old_oldMainPage
Maybe I can delete the navigation cache? I have tried this but the compiler tells me it's read only:
this.NavigationCacheMode = System.Windows.Navigation.NavigationCacheMode.Disabled;
My current navigation code it's:
NavigationService.Navigate(new Uri("/Properties.xaml",UriKind.RelativeOrAbsolute));
and
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决 Windows Phone Silverlight 应用程序中的循环导航 已考虑到此问题而实现。
或者,您可以返回并刷新主页,而不是向前导航到主页的新实例(如果您觉得这样更自然)。
Solving Circular Navigation in Windows Phone Silverlight Applications has been implemented with this problem in mind.
Alternatively you could GoBack and refresh your main page rather than navigate forward to a new instance of your main page if you find that more natural.