【发布时间】:2020-05-07 15:13:01
【问题描述】:
我们使用Xamarin.Forms 和MacOS,并有一个自定义视图MyCustomView : Xamarin.Forms.ContentView,我正在尝试为我们的视图创建一个自定义视图渲染器,但它会干扰渲染视图。
有人知道如何在我的平台项目中创建视图渲染器吗?
这是我到目前为止尝试过的代码,正在寻找类似的地方:
[assembly: Xamarin.Forms.ExportRenderer(typeof(MyCustomView), typeof(MyCustomViewRenderer))]
namespace Mac.Renderers
{
public class MyCustomViewRenderer : ViewRenderer<Xamarin.Forms.ContentView, AppKit.NSView>
{
public MyCustomViewRenderer()
{
// My implementation
}
}
}
实现留空时的事件,有这个自定义渲染器会影响 ContentView 的显示,所以我认为这段代码一定不对 - 有没有办法做到这一点?
【问题讨论】:
-
“正在影响 ContentView 的显示,所以我认为这段代码一定不对”是什么意思?它以何种方式受到影响?
标签: xamarin xamarin.forms xamarin.mac