gpt4 book ai didi

xamarin.forms - 系统无效操作异常: Page must not already have a parent

转载 作者:行者123 更新时间:2023-12-02 10:03:22 25 4
gpt4 key购买 nike

在我的 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.

来源:official documentation

关于xamarin.forms - 系统无效操作异常: Page must not already have a parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50178222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com