<!--CornerRadius for chip group ItemsSource-->
<local:CustomChipGroup
ItemsSource="{Binding Items}"
DisplayMemberPath="Name"
CornerRadius="0"/>
<Label Margin="0,30,0,10" Text="Using Items" FontAttributes="Bold"/>
<!--CornerRadius for chip group Items-->
<local:CustomChipGroup CornerRadius="0">
<local:CustomChipGroup.Items>
<buttons:SfChip Text="John"/>
<buttons:SfChip Text="Mary"/>
<buttons:SfChip Text="Jeny"/>
<buttons:SfChip Text="Mark"/>
</local:CustomChipGroup.Items>
</local:CustomChipGroup> |
public class CustomChipGroup : SfChipGroup
{
public static readonly BindableProperty CornerRadiusProperty =
BindableProperty.Create("CornerRadius", typeof(Thickness), typeof(CustomChipGroup), GetDefaultCornerRadius(), BindingMode.TwoWay, null, null);
public Thickness CornerRadius
{
get { return (Thickness)GetValue(CornerRadiusProperty); }
set { this.SetValue(CornerRadiusProperty, value); }
}
public CustomChipGroup()
{
this.ChipLayout.ChildAdded += ChipLayout_ChildAdded;
}
private static Thickness GetDefaultCornerRadius()
{
if (Device.RuntimePlatform == Device.Android)
{
return 40d;
}
return 15d;
}
private void ChipLayout_ChildAdded(object sender, ElementEventArgs e)
{
if (e.Element is SfChip)
{
(e.Element as SfChip).SetBinding(SfChip.CornerRadiusProperty, new Binding() { Path = "CornerRadius", Source = this, Mode = BindingMode.TwoWay });
}
}
} |
CornerRadius – 0
|
CornerRadius – 20
|
Hi,There are properties to set the chip border color, border width, etc but I can't see a way to set the corner radius for buttons in a SfChipGroup.Thanks,
Scott
public class CustomChipGroup : SfChipGroup
{
. . .
protected override void OnChildAdded(Element child)
{
base.OnChildAdded(child);
child.ChildAdded += Child_ChildAdded;
}
private void Child_ChildAdded(object sender, ElementEventArgs e)
{
if (e.Element is SfChip)
{
(e.Element as SfChip).SetBinding(SfChip.CornerRadiusProperty, new Binding() { Path = "CornerRadius", Source = this, Mode = BindingMode.TwoWay });
}
}
protected override void OnChildRemoved(Element child)
{
child.ChildAdded -= Child_ChildAdded;
base.OnChildRemoved(child);
}
. . .
}
|