在xamarin表单中,如何在单击按钮时关闭内容页并将其从堆栈中移除?

在xamarin表单中,如何在单击按钮时关闭内容页并将其从堆栈中移除?,xamarin,xamarin.forms,Xamarin,Xamarin.forms,要关闭按钮单击上的内容页并将其从堆栈中删除,那么如何实现这一点。PopAsync对我不起作用。要删除导航堆栈中的某些页面,可以使用 this.Navigation.RemovePage (this.Navigation.NavigationStack [your page index]); 但如果您只想返回屏幕或转到导航堆栈的主页面,您可以使用此选项 this.Navigation.PopAsync (); this.Navigation.PopToRootAsync(); 你需要打电话 A

要关闭按钮单击上的内容页并将其从堆栈中删除,那么如何实现这一点。PopAsync对我不起作用。

要删除导航堆栈中的某些页面,可以使用

this.Navigation.RemovePage (this.Navigation.NavigationStack [your page index]);
但如果您只想返回屏幕或转到导航堆栈的主页面,您可以使用此选项

this.Navigation.PopAsync ();
this.Navigation.PopToRootAsync();
你需要打电话

Application.Current.MainPage.Navigation.PopAsync();
来自异步void。 例如,如果有按钮单击处理程序,只需在void之前添加async关键字,如下所示:

private async void Button_Clicked(object sender, EventArgs e)
   {

       await Application.Current.MainPage.Navigation.PopAsync();

   }

你能给我们看看你的代码吗?PopAsync通常是最好的方法。您使用的是导航页面吗?不建议使用没有任何解释的代码。