In Xamarin.Forms, typically I'd write a custom renderer for buttons using a class name like "ButtonExt". Is it possible to write a custom renderer using the original name of (I guess overriding) the element, like "Button"?
Basically, I want to be able to add horizontal padding to all the buttons in my app, but without having to rename all Button
s to ButtonExt
(there is no Padding property for Buttons in Xamarin.Forms). In other words I want to be able say new Button { Padding = 20 }
and not have to say new ButtonExt { Padding = 20 }
(project is C#, not XAML).
Normally, in the iOS project, I'd have:
[assembly: ExportRenderer(typeof(ButtonExt), typeof(ButtonExtRenderer))]
namespace StoreFulfillment.iOS
{
public class ButtonExtRenderer : ButtonRenderer
and in the shared project, I'd have:
using MySharedProject;
using Xamarin.Forms;
namespace MySharedProject.Renderers
{
public class ButtonExt : Button
{
...
And then I'd say new ButtonExt { Padding = 20 }
. But in order to be able to write new Button { Padding = 20 }
, I can't write public class Button : Button
...so how do I accomplish this?