Windows Phone后退按钮问题

发布于 2024-10-10 07:19:09 字数 1075 浏览 0 评论 0原文

我有一个有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

定格我的天空 2024-10-17 07:19:09

解决 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文