xamarin.ios - Xamarin.Forms - Possible to write custom renderer using original element name? -
in xamarin.forms, typically i'd write custom renderer buttons using class name "buttonext". possible write custom renderer using original name of (i guess overriding) element, "button"?
basically, want able add horizontal padding buttons in app, without having rename button
s buttonext
(there no padding property buttons in xamarin.forms). in other words want able new button { padding = 20 }
, not have new buttonext { padding = 20 }
(project c#, not xaml).
normally, in ios project, i'd have:
[assembly: exportrenderer(typeof(buttonext), typeof(buttonextrenderer))] namespace storefulfillment.ios { public class buttonextrenderer : buttonrenderer
and in shared project, i'd have:
using mysharedproject; using xamarin.forms; namespace mysharedproject.renderers { public class buttonext : button { ...
and i'd new buttonext { padding = 20 }
. in order able write new button { padding = 20 }
, can't write public class button : button
...so how accomplish this?
sure! register normal button
type , make sure call base methods of ones override original working remains.
so attribute register renderer this:
[assembly: exportrenderer(typeof(button), typeof(yourbuttonrenderer))]
also, make sure need custom renderer. if want have simple styling issue, @ xamarin.forms styling possibilities , implicit styling.
Comments
Post a Comment