在我的 Xamarin.Forms 应用程序中,我有以下代码:
while (this.Navigation.ModalStack.Count > 0)
{
await this.Navigation.PopModalAsync();
}
await Navigation.PushModalAsync(App.MyMasterDetailPage.Value);
在最后一行,我收到错误
System.InvalidOperationException: Page must not already have a parent.
当我已经从 ModalStack
中弹出所有内容时,MyMasterDetailPage
怎么可能有父级?我只将它推送到 ModalStack
最佳答案
A MasterDetailPage is designed to be a root page, and using it as a child page in other page types could result in unexpected and inconsistent behavior. In addition, it's recommended that the master page of a MasterDetailPage should always be a ContentPage instance, and that the detail page should only be populated with TabbedPage, NavigationPage, and ContentPage instances. This will help to ensure a consistent user experience across all platforms.
关于xamarin.forms - 系统无效操作异常: Page must not already have a parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50178222/