当前位置: 动力学知识库 > 问答 > 编程问答 >

xamarin - Which renderer will be called if we have multiple renderer for same control?

问题描述:

I am working on a Xamarin Forms app where I am struck with 2 issues

First:

I have my custom button renderer and it is working fine. Now I have included reference of another project which have it's own button render. In this case there are two renderer for button. Which will be called and how??

Second:

What if I want to make use of both of the renders?

What I have tried:

Inherited my renderer from the renderer of the referenced project, but it won't work.I am confused with registration of this two renderers.How to register my renderer if inherited from other one.

网友答案:

For your second question, always create a new class that inherit XF's control, so that the control and renderer would be one-one relationship.

[assembly: ExportRenderer(typeof(Button), typeof(MyApp.Renderers.CustomButtonRenderer))] //bad

[assembly: ExportRenderer(typeof(CutomButton), typeof(MyApp.Renderers.CustomButtonRenderer))] //good
分享给朋友:
您可能感兴趣的文章:
随机阅读: