Hello,
Welcome to our Microsoft Q&A platform!
You can create a public static Stack
in the MainPage. After you Navigation.PushModalAsync(new Page1());
, you can push a value to Stack
with NavigationStack.Push("MainPage");
, If you Navigation.PopModalAsync();
in the Page1, MainPage's OnAppearing method will execute, you can check the value. You can check the stack in other page as well.
Please refer to the following link.
static Stack NavigationStack;
public MainPage()
{
NavigationStack = new Stack();
InitializeComponent();
BindingContext = this;
}
private void Button_Clicked(object sender, EventArgs e)
{
Navigation.PushModalAsync(new Page1());
NavigationStack.Push("MainPage");
}
protected override void OnAppearing()
{
base.OnAppearing();
if (NavigationStack.Contains("MainPage"))
{
DisplayAlert("info","you back","OK");
}
}
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.