【问题标题】:Unable to activate instance of type NavigationPageRenderer无法激活 NavigationPageRenderer 类型的实例
【发布时间】:2017-03-18 02:30:35
【问题描述】:

我有一个 MasterDetailPage,这个页面被推送到导航:

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

加载主设备页面后,主页面的列表视图将选择其中一个页面并将其显示在详细信息屏幕上。

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;
            }
        };

错误发生在 Detail = new NavigationPage 部分。

没有找到构造函数 Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)

无法激活类型的实例 Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer 来自 本机句柄 0x85300019 (key_handle 0x42c360f8)。

【问题讨论】:

标签: xamarin xamarin.forms navigation master-detail


【解决方案1】:

您可以尝试提供构造函数来修复它

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

但是 MasterDetailPage 不应该被推送到导航堆栈。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-26
  • 1970-01-01
  • 2011-02-23
  • 1970-01-01
  • 2011-08-14
相关资源
最近更新 更多