[英]Not able to do PopAsync, PopModalAsync and PopToRootAsync from the content page
我正在使用代碼從一個頁面導航到另一個頁面
await Application.Current.MainPage.Navigation.PushModalAsync(new IntercomRecieveCallPage());
從 IntercomRecieveCallPage 我使用以下代碼導航到 IntercomCallPage
await Application.Current.MainPage.Navigation.PushModalAsync(new IntercomCallPage());
從 IntercomCallPage 我正在嘗試使用以下代碼進行后退導航
await App.Current.MainPage.Navigation.PopModalAsync();
但我收到以下異常
指數超出范圍。 必須是非負數且小於集合的大小。 參數名稱:索引
我還嘗試了 PopAsync,即以下代碼
await App.Current.MainPage.Navigation.PopAsync(true);
為此,我也得到了同樣的例外。 我嘗試使用以下代碼清除導航堆棧
Navigation.RemovePage(rootPage);
但它仍然沒有幫助。 我不知道如何解決這個問題。 有什么建議么?
根據 Modals page popping上的文檔,只需擁有 .PopModalAsync( ) 就足夠了。
就像評論一樣,我認為它不會有太大變化,但也許要確保您從同一個命名空間(app.Current 與 Application.Current)調用這兩種方法。
但是,在我這邊進行測試時,push 和 pop 似乎都可以正常工作(即使使用應用程序或應用程序)。
但是,作為下一步,我建議您使用與 IntercomCallPage 不同的頁面來測試您的用例。 只是為了排除此頁面包含會導致加載/重新加載而不是導航調用錯誤的列表的可能性。
在推第二個之前嘗試彈出第一個:
await Application.Current.MainPage.Navigation.PopModalAsync();
await Application.Current.MainPage.Navigation.PushModalAsync(new IntercomCallPage());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.