Reputation: 23
Steps to reproduce the issue 1. clicking the item in details page. 2. Page will open and 3. again open the page and 4. clicking the same item another item page will display on the existing item page
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
Detail.Navigation.PushAsync(new AgreeTerms());
}
EDIT
First of all i given clarification on my issue
AgreeTerms() are sup-rate page and
This page, I navigate the page through masterpage(Menu page, Here I give the link to navigate "AgreeTerms" page), While click on link "AgreeTerms" page open and again click same link page open another page(overlap previous page), The Code to navigate page in masterpage ,
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
Detail.Navigation.PushAsync(new AgreeTerms());
}
and while navigate the page(AgreeTerms) , I want to close the page(AgreeTerms) again, Here I write the code , This is code in AgreeTerms page
private async void Deleteimg_Tapped(object sender, EventArgs e)
{
if (Navigation.NavigationStack.Count > 0 || Navigation.NavigationStack.Last().GetType() != typeof(AgreeTerms))
{
Navigation.PopAsync(false);
}
}
Upvotes: 1
Views: 1358
Reputation: 371
You can do it like this:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
if (Navigation.NavigationStack.Where(x => x is AgreeTerms).Count() > 0)
return;
Detail.Navigation.PushAsync(new AgreeTerms());
}
Upvotes: 1
Reputation: 1074
The question a little confusing, but I think that you want to prevent the same page from opening twice.
If this is the case, you could check current page's type and only Push if it's different from the type that will be pushed. Like so:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
if (Detail.Navigation.NavigationStack.Last().GetType() != typeof(AgreeTerms))
Detail.Navigation.PushAsync(new AgreeTerms());
}
Hope it helps!
EDIT
Forget about Deleteimg_Tapped
, you can delete this method from AgreeTerms
.
You only need to change the OnTapGestureMenuTermsAndConditionsTapped
to the code that I posted up here.
If you change from this:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
Detail.Navigation.PushAsync(new AgreeTerms());
}
To this:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
if (Detail.Navigation.NavigationStack.Last().GetType() != typeof(AgreeTerms)) // Only add this line
Detail.Navigation.PushAsync(new AgreeTerms());
}
It will work.
Upvotes: 0