user1924391
user1924391

Reputation: 255

Programmatically go back

In my application, the user goes from Page A to Page B.

Is there any way to programmatically simulate the back button press? I have a button on Page B and when the user clicks it, I want to go BACK to page A. I don't want to use the NavigationService and navigate to page A, I want to go back to Page A as if the user clicked on the hardware back button. Is there any way to do that?

Upvotes: 4

Views: 4706

Answers (2)

A little addition to Michaël Hompus's answer -- on UWP both CanGoBack property and GoBack method are located in Page.Frame.

Upvotes: 0

Michaël Hompus
Michaël Hompus

Reputation: 3479

Although you say you don't want to use it, the NavigationService.GoBack method is the way to go:

if (this.NavigationService.CanGoBack)
{
    this.NavigationService.GoBack();
}

Upvotes: 23

Related Questions