<buttons:SfChipGroup x:Name="SfChipGroup" Type="Action">
<buttons:SfChipGroup.Items>
<buttons:SfChip CornerRadius="{Binding CornerRadius,Mode=TwoWay}" Text="Extra"/>
<buttons:SfChip CornerRadius="{Binding CornerRadius,Mode=TwoWay}" Text="Small"/>
<buttons:SfChip CornerRadius="{Binding CornerRadius,Mode=TwoWay}" Text="Medium"/>
<buttons:SfChip CornerRadius="{Binding CornerRadius,Mode=TwoWay}" Text="Large"/>
</buttons:SfChipGroup.Items>
</buttons:SfChipGroup> |
<buttons:SfChipGroup ItemsSource="{Binding Items}» >
employees = new ObservableCollection<SfChip>(); employees.Add(new SfChip() { Text= "John", CornerRadius= 10 }); employees.Add(new SfChip() { Text = "James", CornerRadius = 10 }); |
public class CustomChipGroup : SfChipGroup { #region CornerRadius 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); } } #endregion public CustomChipGroup() { this.ChipLayout.ChildAdded+= ChipLayout_ChildAdded; } #region Default corner radius private static Thickness GetDefaultCornerRadius() { if (Device.RuntimePlatform == Device.Android) { return 40d; } return 15d; } #endregion 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}); } } } |
<StackLayout> <Label Margin="0,30,0,10" Text="Using ItemsSource" FontAttributes="Bold"/> <local:CustomChipGroup ItemsSource="{Binding Items}" DisplayMemberPath="Name" CornerRadius="0"/> <Label Margin="0,30,0,10" Text="Using Items" FontAttributes="Bold"/> <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> </StackLayout> |