如何防止返回上一页 [英] how to prevent going back to previous page

查看:35
本文介绍了如何防止返回上一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我正在开发的 Windows Phone 8 应用程序,我必须在应用程序启动时加载一些数据.为此,我设计了一个名为 SplashScreen.xaml 的页面来加载数据,在所有加载完成后,我使用:

For a windows phone 8 app I'm developing, I had to load some data at the starting of the app. For that matter I designed a page called SplashScreen.xaml that loads the data and after all the loading is done I navigate to the MainPage.xaml using:

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

现在,当用户在主页面并点击手机上的后退按钮而不是离开应用程序(这是默认手势)时,将返回到 SplashScreen.xaml,使他们无法退出应用程序(除了点击将应用程序带到后台的开始按钮),当然会给他们留下不好的印象.问题是如何防止回到上一页谢谢大家.

Now when the user is in the main page and taps the back button on the phone instead of going out of the app(which is the default gesture) goes back to the SplashScreen.xaml, making them unable to go out of the app(except for taping the start button which take's the app to background) and of course giving them a bad impression. The question is How to prevent going back to the previous page Thank you all.

推荐答案

登陆MainPage时只需清除backstack:

Just clear the backstack when landing on MainPage:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    while (NavigationService.RemoveBackEntry() != null);
}

这篇关于如何防止返回上一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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