dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.2k stars 152 forks source link

[Request] Add a guide for contributing control wrappers and properties #33

Open davidortinau opened 4 years ago

davidortinau commented 4 years ago

I'd like a guide for how to add properties to existing controls, such as Button which is currently missing font size and borders, and new controls such as BoxView.

Screenshot 2020-01-11 08 54 45

That in addition to a backlog of known work items would be great to enlist help.

sps014 commented 4 years ago

Agree with @DavidKarlas , can't wait to Contribute.

0x414c49 commented 4 years ago

I was checking the source code today, in Microsoft.MobileBlazorBindings/Elements the source of all control wrappers are available.

For eg, button element:

    public class Button : View
    {
        static Button()
        {
            ElementHandlerRegistry
                .RegisterElementHandler<Button>(renderer => new ButtonHandler(renderer, new XF.Button()));
        }
        // ... rest of the code

        // new property added, Font property is the same as XamarinFormsButton Font property
        // https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.button.font?view=xamarin-forms
        [Parameter] public XF.Font? Font {get;set;}

       // rest of the code

And apply it with RenderAttribute method:

        protected override void RenderAttributes(AttributesBuilder builder)
        {
            base.RenderAttributes(builder);
            // ... rest of the code
            if(Font != null)
            {
                builder.AddAttribute(nameof(Font), Font);
            }
           // ... rest of the code
        }

Agree with all, I cannot wait to contribute.