问题
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