Skip to main content Skip to footer

C1ComboBox - Display Selected Item at the Top

We will make use of the SelectedItemChanged event in here and after selecting the respective Item from the underlying ObservableCollection, will insert it at the zeroth index in the Collection.


int index;  
void c1ComboBox_SelectedItemChanged(object sender, C1.WPF.PropertyChangedEventArgs<object> e)  
{  
    //Get the index position of the currently selected item in the ComboBox  
    index = c1ComboBox.SelectedIndex;  
    //Get the Item  
    Employee emp1 = (Employee)c1ComboBox.SelectedItem;  

    if (index >= 0)  
    {  
       c1ComboBox.ItemsSource = null;  
       //Remove the item from its original index in the Collection  
       emp.RemoveAt(index);  
       //Insert it in the first place in the Collection  
       emp.Insert(0, emp1);  
       c1ComboBox.ItemsSource = emp;  
    }  
}