Xaml NavigationService.GoBack在Windows Phone 8中不工作

Xaml NavigationService.GoBack在Windows Phone 8中不工作,xaml,windows-phone-8,Xaml,Windows Phone 8,我正在开发WindowsPhone8应用程序 我的应用程序页面结构 1.欢迎页面(获取位置)-> 2.MainPage.xaml(包含六个按钮,例如:酒店、公园、寺庙…)-> 3.酒店(现有酒店列表单击任何酒店)-> 4.MoreDetailsPage(在应用程序中的浏览器中提供特定酒店的详细信息) 在MoredetailPage中,我使用NavigationService.GoBack();OnBackkeyPress事件。如果我按Back键,它将关闭并退出应用程序 我对每一页的编码:- We

我正在开发WindowsPhone8应用程序

我的应用程序页面结构

1.欢迎页面(获取位置)->

2.MainPage.xaml(包含六个按钮,例如:酒店、公园、寺庙…)->

3.酒店(现有酒店列表单击任何酒店)->

4.MoreDetailsPage(在应用程序中的浏览器中提供特定酒店的详细信息)

在MoredetailPage中,我使用NavigationService.GoBack();OnBackkeyPress事件。如果我按Back键,它将关闭并退出应用程序

我对每一页的编码:-

WelcomePage.xaml

在重新地理编码时,查询已完成事件

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

点击事件

this.NavigationService.Navigate(new Uri("/Hotels.xaml", UriKind.Relative)); 
删除WelcomePage.xaml的回溯条目

protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        NavigationService.RemoveBackEntry();
    }
Hotels.xaml

在列表框上点击事件

   this.NavigationService.Navigate(new Uri(string.Format("/Moredetailswebpage.xaml?Businessname={0}", passvalue), UriKind.Relative));
更多详情webpage.xaml

PhoneApplicationPage\加载的事件

minbrowser.Navigate(new Uri(site, UriKind.Absolute));
反按键

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
        try
        {
            base.OnBackKeyPress(e);
            NavigationService.GoBack();
        }
        catch (Exception ex)
        {
        }
    }
如果单击MoreDetailpage.xaml中的hardware backkey。它只是关闭并退出应用程序

请告诉我如何解决这个问题。我在哪里犯了错误。

你说过按Back键你的应用程序会退出吗? 下面是一个不让它退出的例子

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{

      //Forces the app not to quit
      e.Cancel = true;          

}

我认为应用程序在按back键时崩溃了?如果没有检查,backstack中是否存在任何条目?@vits如何检查backstack.NavigationService.CanGoBack()中存在的条目;另外,像这样的总条目,int stackSize=0;foreach(NavigationService.BackStack中的var屏幕){stackSize++;}如果(this.NavigationService.CanGoBack){this.NavigationService.GoBack();}它将进入this.NavigationService.GoBack()中;