问题
I've done some reading and found that one can only close a windows phone app by throwing an un-handled exception that will close the app.
So my question is, how does one do that for the physical back button on the phone?
And how does one have the back button close the app only if it's on a certain page ?
So the back button would work as normal, but when it eventually falls on a page called 'noBack.xaml' the back button should close the app.
EDIT
Actually on second thought, even just disabling the back button on that page would be awesome...
thanks! :)
回答1:
Just clear the backstack when you're on NoBack.xaml
:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
while (this.NavigationService.BackStack.Any())
{
this.NavigationService.RemoveBackEntry();
}
}
This way, the next time the user press the back button, it will exit the application.
来源:https://stackoverflow.com/questions/13417380/close-app-on-back-button-when-on-certain-page