user3162111
user3162111

Reputation: 21

In windows phone, How to do "Clicking on back button should close the app"?

Hi i am working on one app having menupage.If user is in menupage and press back button of the phone, I want the application to be closed. Currently if i am pressing back button it navigates to previous pages.

Please Help me, Genuine help is appreciated.

Upvotes: 0

Views: 92

Answers (2)

Igor Kulman
Igor Kulman

Reputation: 16361

You need to clear the BackStack on that page (ideally in OnNavigatedTo)

while (this.NavigationService.BackStack.Any())
{
   this.NavigationService.RemoveBackEntry();
}

Upvotes: 1

vITs
vITs

Reputation: 1560

Put this code when you need to close your application.

Application.Current.Terminate();

Upvotes: 0

Related Questions