Windows Phone 8:返回按钮 [英] Windows Phone 8: Back Button

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

问题描述

我是 Windows Phone 平台的新手.我正在尝试制作新闻应用程序.在这个应用程序中,用户点击并阅读新闻文章,之后,用户想返回主页再次查看所有新闻标题,并再次点击其他新闻.

I'm new on windows phone platform. I'm trying to make a news application. On this application, user clicks and reads the article of news, after, user wants to came back to mainpage to see all news headers again, and will click the other news again.

但是当用户在阅读第一篇文章后返回主页时,用户点击了第二个新闻标题.但是当用户导航到新页面时,第一篇新闻文章还在那里.

But when the user comes back to mainpage after reading first article, user clicks second news header. But when user navigates to new page, first news article is still there.

我想问一下,当用户(在阅读第一篇新闻文章后)按下返回主页时,是否有任何返回按钮用于清除文章页面的缓存?

I wanna ask this, is there any back button for user (after reading first news article) to use for clearing cache of article page when he or she presses to come back mainpage ?

我用过这个但它没有;

private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)
{
    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}

我在 httprequest 下写了一些东西,但它对我也不起作用;

I wrote something under my httprequest, but it didnt worked for me too;

private void LiveLongListSelector_Loaded(object sender, RoutedEventArgs e)
{
    string url = "MYWEBAPIURL&rnd=" + new Random().Next(1,1000);
    HttpWebRequest hWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
    hWebRequest.Method = "GET";
    hWebRequest.BeginGetResponse(ResponseLive_Completed, hWebRequest);
    hWebRequest.Headers[HttpRequestHeader.CacheControl] = "no-cache";
    hWebRequest.Headers[HttpRequestHeader.CacheControl] = "no-cache";
    hWebRequest.Headers["Cache-Control"] = "no-cache";
    hWebRequest.Headers["Pragma"] = "no-cache";
}

谁能帮我找到那个完美的后退按钮或其他东西?

Can anyone help me to find that perfect back button or other thing ?

非常感谢

推荐答案

只需使用NavigationService.GoBack();而不是使用

NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));

它会自动清除所有捕获.

It will clear all catch automatically.

或者你可以在再次阅读第二篇文章时使用NavigationService.RemoveBackEntry();.使用类似-

or you can use NavigationService.RemoveBackEntry(); when coming again to read second article. Use something like-

int a = NavigationService.BackStack.Count();
while (a > number) //number is stack count when comes to main page first time
{
     this.NavigationService.RemoveBackEntry();
     a = NavigationService.BackStack.Count();
}

这篇关于Windows Phone 8:返回按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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