Unable to activate instance of type NavigationPageRenderer

限于喜欢 提交于 2019-12-11 06:35:26

问题


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:


You can try to fix it supplying constructor

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

BUT MasterDetailPage should be never pushed to Navigation stack.



来源:https://stackoverflow.com/questions/40419574/unable-to-activate-instance-of-type-navigationpagerenderer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!