2
votes

I navigate through different pages in my application. At some time I come to my home page and by pressing the back button I want to exit my application while I am at homepage but each time I press the back button it goes to the previous page. I succeed to cancel the navigation overriding the backkeypress property of the application.

protected override void OnBackKeyPress(CancelEventArgs e)
    {
        base.OnBackKeyPress(e);
         e.cancel = true;
   }

Is there any similar way to exit the application ?

3

3 Answers

3
votes

AFAIK - there is no API to exit your app. It is supposed to only be done by the user and rightly so, since an app exiting in a non-standard way would confuse a user. I think the only way to exit your app is to get an unhandled exception, but if you make that into a feature - your app might not pass certification.

1
votes

Just remove e.cancel = true; and try again

-1
votes
        this.NavigationService.RemoveBackEntry();
        base.OnBackKeyPress(e);
        e.Cancel = false;