how to prevent going back to previous page

北慕城南 提交于 2019-12-09 03:24:52

问题


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));

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.


回答1:


Just clear the backstack when landing on MainPage:

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


来源:https://stackoverflow.com/questions/19071652/how-to-prevent-going-back-to-previous-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!