I have 3 pages in my application- MainPage, Page1 and Page2.
Page2 contains a button , when the button is clicked the following code gets executed-
Navigation.PushAsync(new Page1());
Page 1 gets loaded.
Now when I press the back button on Page1, I want it to load the MainPage, but instead Page2 gets loaded.
I have tried overriding the back button-
protected override bool OnBackButtonPressed()
{
Navigation.PushAsync(new MainPage());
return true;
}
And also using
Navigation.PopAsync();
But neither of them worked.