Unable to activate instance of type NavigationPage

2019-08-03 04:58发布

I have a MasterDetailPage and this page get pushed to a Navigation:

await MainPage.Navigation.PushAsync(new MasterDevicePage());

when the master device page get loaded, the master page's list view will then select one of the page and display it on the detail screen.

masterPage.ListView.ItemSelected += (sender, e) =>
        {
            var item = e.SelectedItem as MasterPageModel;
            if (item != null)
            {
                Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
                Detail.Title = item.Title;
                masterPage.ListView.SelectedItem = null;
                IsPresented = false;
            }
        };

The error occurs at the Detail = new NavigationPage part.

No constructor found for Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)

Unable to activate instance of type Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer from native handle 0x85300019 (key_handle 0x42c360f8).

1条回答
走好不送
2楼-- · 2019-08-03 05:34

You can try to fix it supplying constructor

public YourClass (IntPtr javaReference, JniHandleOwnership transfer)
            : base ()
        {
        }

BUT MasterDetailPage should be never pushed to Navigation stack.

查看更多
登录 后发表回答