System.InvalidOperationException: 页面不能已经有父页面
System.InvalidOperationException: Page must not already have a parent
在我的 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 应用程序中,我有以下代码:
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.