Xamarin.forms: [Enhancement] Rounded corners on BoxView

Created on 26 Jan 2018  Â·  8Comments  Â·  Source: xamarin/Xamarin.Forms

Rationale

Forms does not currently support rounded corners on BoxView.

Implementation

Add a CornerRadius bindable property to BoxView (using the same struct as in https://github.com/xamarin/Xamarin.Forms/issues/1664).

public static readonly BindableProperty CornerRadiusProperty =
BindableProperty.Create(nameof(CornerRadius), typeof(CornerRadius), default(CornerRadius));

On iOS, this will likely require checking for a non-zero radius and switching to a UIBezierPath for drawing. On UWP, it's likely just a matter of applying the RadiusX/RadiusY properties to the underlying Rectangle. On Android, it probably just requires overriding Draw and applying a clipping path.

Backward Compatibility

This is a new property, so there should not be any backward compatibility issues.

Difficulty: Easy

F100 community-sprint enhancement âž•

All 8 comments

@jsuarezruiz for you

It might be worth considering generalizing this to generic interface we can apply to all views (or at least a few of the easier ones, to start with).

I think it's a great idea. There are requests for the same with a StackLayout, etc.
Do we complete this Issue and create another one later?

Keep rolling on this one, I'm going to write up a separate proposal for IRoundedCorners and depending on timing, we can either update this to implement that interface or call this "phase 1" of that proposal.

I have an app in Develop with Xamarin i bee so happy if target 3.1.0 release soon :D

What kind of value is this CornerRadius? E.g. which value do I set if I want to make a circle? Definitely not a percentage of the width/height which would have been the easiest to work with...

Was this page helpful?
0 / 5 - 0 ratings