简体   繁体   English

WP7-没有导航服务的后退按钮

[英]WP7 - Back Button without Navigation Service

Is it possible to some how capture the Back Button Event without using the Navigation Service? 是否可以在不使用导航服务的情况下捕获后退按钮事件?

A previous post here on StackOverflow describes the the Back Button Events (both the overload of OnBackKeyPress and the event handler PhoneApplicationPage_BackKeyPress ) only seem to fire when the navigation service is used. 此处有关StackOverflow一篇文章描述了“后退按钮事件”( OnBackKeyPress和事件处理程序PhoneApplicationPage_BackKeyPress的重载)仅在使用导航服务时才触发。

My implementation is: 我的实现是:

//Prepare the page;
NextPage page = new NextPage();

//When we are ready to transition
page.someData = data;
page.parent = this;
this.Content = page;

I'm using this so that I can store the page for use later (essentially so that I can cache it, especially since some of my pages download information from the internet, and so that I can pass it data like above. However, I still need to use the back button to return to the home page. 我正在使用它,以便我可以存储页面供以后使用(本质上是为了可以缓存它,尤其是因为某些页面从Internet下载信息,以便像上面那样传递数据。但是,我仍然需要使用“后退”按钮返回首页。

Is there anyway to trigger the back button while using the above method? 使用上述方法时是否有触发后退按钮的问题?

Storing a whole page to cache the data is a bad idea especially in a limited environment like .Net CF. 存储整个页面以缓存数据是一个坏主意,尤其是在.Net CF这样的有限环境中。

  • it complicates the app (complicated navigation logic, possible cycles) 它会使应用程序复杂化(复杂的导航逻辑,可能的周期)
  • app is limited to 90MB of memory 应用限制为90MB的内存

Store the data in IsolatedStorageSettings.ApplicationSettings when dealing with relatively small amount of data eg couple of strings, xml file < 1KB. 当处理相对少量的数据(例如,几个字符串,xml文件<1KB)时,将数据存储在IsolatedStorageSettings.ApplicationSettings中。 Otherwise store the data in a file in Isolated Storage eg music, pictures, huge xmls etc. 否则,将数据存储在独立存储中的文件中,例如音乐,图片,巨大的xml等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM