I have an application which displays a disclaimer page when it is first run. Once you select Accept or Deny you never see the page again.
However, when you press the back key attempting to close the application after the first run, you go back to the disclaimer page, then if you hit it again, back to the main page and then again to exit.
This only happens the first time the application is run, but I would like to have the application ignore the disclaimer page when the back key is pressed and exit the application.
Other than forcing an unhandled exception error to close the app, are there any other options?
Thanks in advance.
Solution: Add the below NavigationService.RemoveBackEntry(); in my main page.
private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
{
NavigationService.RemoveBackEntry();
NavigationService.RemoveBackEntry();
}
I am sure there is a more elegant way to do it, but I was in a hurry, so I implemented it in a following way.
I have a static global enum that stores the last page I was on. Assuming you have pages called
pgDisclaimerandpgMain.In the
OnNavigatedToevent of thepgDisclaimerpage, check to see where the control came from. If it came frompgMain, just executeNavigationService.GoBack()and you’ll be out of the application and the user will never actually seepgDisclaimerpage (not even a flicker).Edit: Found the more elegant way. In Mango, you can use the horribly named
NavigationService.RemoveBackEntry()method.