我有一个基类,如下所示
public class DialogSelectionItem<Tobject> : ViewCell
现在我想将自定义渲染器附加到它:
[assembly: ExportRenderer(typeof(SomeApp.CustomRenderers.DialogSelectionItem<Tobject>), typeof(SomeApp.iOS.CustomRenderers.DialogSelectionItemRenderer))]
namespace SomeApp.iOS.CustomRenderers
{
public class DialogSelectionItemRenderer : ViewCellRenderer
{
// some customizations
}
}
问题是
找不到类型或命名空间名称"Tobject"(是否缺少 using 指令或程序集引用?
我可以改用object
,但永远不会调用自定义渲染器。
是否有选项可以获取正确的类型或使用泛型?我应该如何定义ExportRenderer
?
好的,解决方案发布在这里。
基类:
public class DialogSelectionItem : ViewCell
{
// nothing
}
public class DialogSelectionItem<Tobject> : DialogSelectionItem
{
// do something
}
视图渲染器:
[assembly: ExportRenderer(typeof(SomeApp.CustomRenderers.DialogSelectionItem), typeof(SomeApp.iOS.CustomRenderers.DialogSelectionItemRenderer))]
namespace SomeApp.iOS.CustomRenderers
{
public class DialogSelectionItemRenderer : ViewCellRenderer
{
// some customizations
}
}