Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to avoid open page already exist on Navigation stack? [duplicate]

I am using Xamarin.forms, Some times user will click twice on same button, I am search away to avoid open same page twice, maybe disable the button after first click will work fine, but i am searching away to avoid open same page if page already exist on Navigation stack.

btnCustomerPage.Clicked += (object sender, EventArgs e) => 
{
 //CustomerPage already Exist on Navigation Stack,So user already open it.
 Navigation.PushAsync(new CustomerPage(); 
};
like image 716
Mohamad Mahmoud Avatar asked Feb 21 '17 18:02

Mohamad Mahmoud


1 Answers

if (Navigation.NavigationStack.Count == 0 ||
    Navigation.NavigationStack.Last().GetType() != typeof(CustomerPage))
{
    await Navigation.PushAsync(new CustomerPage(), true);
}
like image 159
pinedax Avatar answered Nov 05 '22 23:11

pinedax