重现问题的步骤 1.单击详细信息页面中的项目。 2.页面将打开和 3.再次打开页面 4.单击同一项目,另一项目页面将显示在现有项目页面上
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
Detail.Navigation.PushAsync(new AgreeTerms());
}
修改
首先,我澄清了我的问题
AgreeTerms()是超率页面和
这个页面,我浏览页面浏览主页(菜单页面,这里我给出了导航链接" AgreeTerms"页面),点击链接" AgreeTerms"页面打开并再次单击相同的链接页面打开另一页(重叠上一页),在主页中导航页面的代码,
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
Detail.Navigation.PushAsync(new AgreeTerms());
}
在导航页面(AgreeTerms)时,我想再次关闭页面(AgreeTerms),在这里我编写代码,这是AgreeTerms页面中的代码
private async void Deleteimg_Tapped(object sender, EventArgs e)
{
if (Navigation.NavigationStack.Count > 0 || Navigation.NavigationStack.Last().GetType() != typeof(AgreeTerms))
{
Navigation.PopAsync(false);
}
}
答案 0 :(得分:0)
这个问题有点令人困惑,但我认为你想阻止同一页面打开两次。
如果是这种情况,您可以检查当前页面的类型,如果它与将要推送的类型不同,则仅推送。像这样:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
if (Detail.Navigation.NavigationStack.Last().GetType() != typeof(AgreeTerms))
Detail.Navigation.PushAsync(new AgreeTerms());
}
希望它有所帮助!
修改强>
忘记Deleteimg_Tapped
,您可以从AgreeTerms
删除此方法。
您只需将OnTapGestureMenuTermsAndConditionsTapped
更改为我在此处发布的代码。
如果你改变了:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
Detail.Navigation.PushAsync(new AgreeTerms());
}
对此:
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());
}
它会起作用。
答案 1 :(得分:0)
你可以这样做:
void OnTapGestureMenuTermsAndConditionsTapped(object sender, EventArgs args)
{
IsPresented = false;
if (Navigation.NavigationStack.Where(x => x is AgreeTerms).Count() > 0)
return;
Detail.Navigation.PushAsync(new AgreeTerms());
}