Reputation: 7710
I use this method to close my app:
public void quit()
{
if (NavigationService.CanGoBack)
{
while (NavigationService.RemoveBackEntry() != null)
{
NavigationService.RemoveBackEntry();
}
}
}
When I call it after pressing back key, the app closes as intended:
protected override void OnBackKeyPress(CancelEventArgs e)
{
quit();
}
But anywhere else I call this method, the stack is emptied but the app will not close.
If I try:
quit();
NavigationService.GoBack();
There will be a runtime error. If anybody can help me because I don't like to through an exception since it will be recorded as a bug in the marketplace statistics.
Upvotes: 0
Views: 73
Reputation: 50672
There is no need to clear the Navigation stack; if the application terminates the navigation stack will be gone. Do not worry about the user going forward; there is no forward key.
To remove the exception:
quit();
if( NavigationService.CanGoBack)
{
NavigationService.GoBack();
}
But before you do this, look at the code: what are you trying to accomplish? First you are cleaning out the stack and then you want to use the stack.
Upvotes: 1