简体   繁体   English

Windows Phone 8数据绑定应用程序和后退按钮

[英]Windows Phone 8 Databound App and back button

I've something that I can't get myself understand. 我有些我无法理解的事情。 I'm making an app with databound template. 我正在使用具有数据绑定模板的应用程序。 I put a textbox on mainpage and a button. 我在主页上放置了一个文本框和一个按钮。 when i type something in textbox and press on button it navigates to the listing page and that content comes from web and then if i press on back button and make a new search the results from previous search stays there. 当我在文本框中键入内容并按一下按钮时,它将导航到列表页面,并且该内容来自网络,然后如果我按后退按钮并进行新的搜索,则先前搜索的结果将保留在那里。 how can i reset/clear or disable cache of that page? 如何重置/清除或禁用该页面的缓存?

It would be helpful if you could post your XAML and code-behind, but I will attempt to make a jab at an answer. 如果您可以发布XAML并进行代码隐藏,这将很有帮助,但是我将尽力回答一个问题。 Where are you referencing the call to get the data from the web? 您在哪里引用该呼叫以从Web获取数据? If it is in the constructor of the page, then that is why the previous search stays there. 如果它在页面的构造函数中,那么这就是为什么以前的搜索停留在那里的原因。 What is probably happening is the first search constructs the secondary page, does your web call, and binds your data to the page. 可能发生的情况是,第一个搜索将构造第二个页面,进行您的Web调用,并将您的数据绑定到该页面。 Then when you press the back button, and click it again, the page is already constructed, so it uses the same data. 然后,当您按下“后退”按钮并再次单击它时,页面已经构建完毕,因此它使用相同的数据。

It is probably wise to call your web service in the OnNavigatedTo override method. 在OnNavigatedTo重写方法中调用Web服务可能是明智的。 From the first page, you can pass parameters to your secondary page (ie, pass the search term, then pass the search term into your web service). 从第一页,您可以将参数传递到第二页(即,传递搜索词,然后将搜索词传递到Web服务中)。

Here is an example of passing parameters between pages: http://developer.nokia.com/Community/Wiki/Passing_parameters_while_navigating_between_pages_on_Windows_Phone 这是在页面之间传递参数的示例: http : //developer.nokia.com/Community/Wiki/Passing_parameters_while_navigating_between_pages_on_Windows_Phone

Also, make sure your Data Context for the second page is appropriately set each time the page is navigated to, since you have a data bound application. 另外,由于您有数据绑定应用程序,因此请确保每次导航到第二页时都正确设置了第二页的数据上下文。

Without code, I can't really help other than giving these things to think about. 没有代码,除了考虑这些事情,我无能为力。

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

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