How to select a chip from back end

I set a simple List as itemsource to SfChipsGroup from back end. When the app launch, the first chip in the group need to be selected already. How can I select the first chip from back end?

qtychipsgroup.ItemSource = myintlist;
qtychipsgroup.SelectedItem = ?

I tried to set the SelectedItem to an int that present in the list, but the chip doesn't appear to change, I mean it is not highlighted like selected.


1 Reply 1 reply marked as answer

SS Sridevi Sivakumar Syncfusion Team August 28, 2020 04:55 PM UTC

Hi Gangatharan Baskaran,

Greetings from Syncfusion.

Query:  How can I select the first chip from the back end?

We would like to let you know that with the populated collection to the ItemsSource property of SfChipGroup with Choice type, you can select the desired chip by using SelectedItem property as per in below   
    
public class ViewModel : INotifyPropertyChanged    
    {    
        private ObservableCollection<Person> employees;    
        public ObservableCollection<Person> Employees    
        {    
            get    
            {    
                return employees;    
            }    
            set    
            {    
                Employees = value;    
                OnPropertyChanged("Employees");    
            }    
        }    
    
        private object selectedItem;    
    
        public object SelectedItem    
        {    
            get    
            {     
                return selectedItem;     
            }    
            set    
            {    
                selectedItem = value;    
                OnPropertyChanged("SelectedItem");    
            }    
        }    
    
        public ViewModel()    
        {    
            employees = new ObservableCollection<Person>();    
            employees.Add(new Person() { Name = "John" });    
            employees.Add(new Person() { Name = "James" });    
            employees.Add(new Person() { Name = "Linda" });    
            employees.Add(new Person() { Name = "Rose" });    
            employees.Add(new Person() { Name = "Mark" });    
            SelectedItem = employees[0];    
        }    
…    
}    
 

 
 
<buttons:SfChipGroup x:Name="chipGroup"    
                                 Type="Choice" DisplayMemberPath="Name"  SelectedItem="{Binding SelectedItem}"    
                                 ItemsSource="{Binding Employees}"     
                                 SelectedChipBackgroundColor="Fuchsia" />    
 
   
  

 

 

 

 
(OR)  
 
   
chipGroup.SelectedItem = new ViewModel().SelectedItem;    
 
  

  


Marked as answer
Loader.
Up arrow icon