We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change individual chip color

Thread ID:

Created:

Updated:

Platform:

Replies:

149409 Nov 25,2019 01:42 PM UTC Nov 26,2019 07:04 AM UTC Xamarin.Forms 1
loading
Tags: SfChip
Artur Aksamit
Asked On November 25, 2019 01:42 PM UTC

Is it possible to set some property (ex. background) for individual chips? I need to have different chips colors inside one group.

Hemalatha Marikumar [Syncfusion]
Replied On November 26, 2019 07:04 AM UTC

Hi Artur, 
  
Greeting from Syncfusion. 
  
You can achieve your requirement by using the ItemTemplate support for SfChipGroup and BackgroundColor property of SfChip. Please refer the below code. 
  
Code Snippet [XAML]: 
<syncfusion:SfChipGroup.ItemTemplate> 
    <DataTemplate> 
        <StackLayout> 
            <syncfusion:SfChip Text="{Binding Name}" BackgroundColor="{Binding ChipColor}"/> 
        </StackLayout> 
    </DataTemplate> 
</syncfusion:SfChipGroup.ItemTemplate> 
  
Code Snippet [C#]: Model class 
public class Model 
{ 
    public string Name { getset; } 
  
    public Color ChipColor { getset; } 
} 
  
Code Snippet [C#]: Viewmodel 
public class ViewModel : INotifyPropertyChanged 
{ 
    public ObservableCollection<Model> Employees 
    { 
        . . . 
    } 
    
    public ViewModel() 
    { 
        employees = new ObservableCollection<Model>(); 
        employees.Add(new Model() { Name = "John", ChipColor = Color.Red }); 
        employees.Add(new Model() { Name = "Stephen", ChipColor = Color.Yellow }); 
        employees.Add(new Model() { Name = "Michael", ChipColor = Color.Pink }); 
        employees.Add(new Model() { Name = "Joel", ChipColor = Color.Gray }); 
    } 
} 
  
  
Please download the prepared sample from below link   
  
   
Screenshot:  
 
  
Please let us know if you need any further assistance on this.  
  
Regards, 
Hemalatha M. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon