NavigationService.GoBack在Windows Phone 8中不起作用

时间:2014-05-15 11:50:44

标签: xaml windows-phone-8

我正在开发windows phone 8应用程序。

我的应用页面结构

1.WelcomePage(的getLocation) - >

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

3.Hotels(酒店列表点击任何一家酒店) - >

4.MoreDetailsPage(关于应用程序中浏览器中的特定酒店)

每件事情都能很好地达到MoredetailPage.In Moredetailpage我使用NavigationService.GoBack(); OnBackkeyPress事件。如果我按Back Key它只是关闭并退出App。

我的每页编码: -

WelcomePage.xaml

关于revgeocoding_QueryCompleted事件。

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

MainPage.xaml中

点击活动。

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

删除WelcomePage.xaml的BackEntry

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

Hotels.xaml

在列表框上点击事件。

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

Moredetailswebpage.xaml

PhoneApplicationPage_Loaded Event

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

OnBackKeyPress

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
        try
        {
            base.OnBackKeyPress(e);
            NavigationService.GoBack();
        }
        catch (Exception ex)
        {
        }
    }

如果我从MoreDetailpage.xaml点击硬件反键。它只是关闭并退出应用程序。

Plz告诉我如何解决这个问题。我犯了错误。

1 个答案:

答案 0 :(得分:0)

你说 Back Key Press 你的应用程序会退出吗? 这是一个不让它退出的例子。

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

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

}
相关问题