Windows Phone 后退键问题 [英] Windows Phone back button problem

查看:22
本文介绍了Windows Phone 后退键问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它有 2 个表单,主表单和一个属性表单,当我单击导航到属性的按钮,然后单击后退按钮(硬件)时,我得到了我所期望的,我的应用程序返回到主窗体,但如果我应用属性并再次导航到主页并再次按下后退按钮,我将返回属性,如果我继续向后推,我可以返回无限属性/主页,这很糟糕,因为主页已更改其属性.

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;

我当前的导航代码是:

NavigationService.Navigate(new Uri("/Properties.xaml",UriKind.RelativeOrAbsolute));
and
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));

推荐答案

解决 Windows Phone Silverlight 应用程序中的圆形导航 已考虑到这个问题.

或者,如果您觉得这样更自然,您可以返回并刷新主页,而不是向前导航到主页的新实例.

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.

这篇关于Windows Phone 后退键问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆