Using subclass of native control with custom renderer


what is the best practise to use a subclass of any control in the native xamarin project?
My problem is following:
I just wanted an unique entry appereance cross android, winphone and iOS. So i have to remove round corners on iOS (no problem - BorderStyle) and bring some padding arround of the text. It seems not to be able to define the padding using a custom renderer. I need to subclass UITextField But how to set the subclass as native control. Calling the SetNativeControl(new MySpecialTextField) ignores all done support of base renderer. I need to set all binding and other properties.


  • adamkempadamkemp USInsider, Developer Group Leader mod

    Yeah, it's really frustrating how inextensible the stock renderers are. You can use reflection to call the private or internal pieces of the base renderer or you can reinvent the whole thing. Those are pretty much your options.

  • nikkanikka USMember ✭✭

    @adamkemp how can I use reflection in that case?

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Here is one example of using reflection to call internal APIs. It's not your exact use case, but it should show you the basic idea. You should look at the .Net reflection APIs to understand the example and what you have to do.

Sign In or Register to comment.