Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Sorting xamComboEditor items
posted

Hey,

I have a BindingList attached to the ItemsSource of a xamComboEditor, but the items seem to be unsorted in the dropdownlist. Is there any way to sort the items of the dropdownlist by the displaymember (which is a string)? I have tried to use the following code but without success.

XAML:  

 

<i

 

 

gEditors:XamComboEditor Height="24" Name="xamComboEditorSample" Width="Auto" xmlns:igEditors="http://infragistics.com/Editors" IsEditable="True" InvalidValueBehavior="RevertValue" EditModeEnded="xamComboEditorSample_EditModeEnded" IsEnabled="False" DropDownResizeMode="Both" DropDownButtonDisplayMode="Always">

   <igEditors:XamComboEditor.ItemsProvider>       

      <igEditors:ComboBoxItemsProvider x:Name="itemsProvider1"/>  

   </igEditors:XamComboEditor.ItemsProvider>  

</igEditors:XamComboEditor> 

CODE:

System.ComponentModel.

SortDescription SD = new System.ComponentModel.SortDescription(); 

SD.Direction = System.ComponentModel.

ListSortDirection.Ascending; 

SD.PropertyName =

"nameFull";  

xamComboEditorSample.ItemsProvider.ValuePath =

 

"guid";

xamComboEditorSample.ItemsProvider.DisplayMemberPath = "nameFull"; 

xamComboEditorSample.ItemsProvider.Items.SortDescriptions.Add(SD); 

xamComboEditorSample.ItemsProvider.ItemsSource = list; //List is here a bindinglist

 

  • 9836
    posted

    Hello ,

    One possible solution is to sort the list before populating the ItemsSource :

    IEnumerable<Person> query = items.OrderBy(i => i.nameFull);

    xamComboEditorSample.ItemsProvider.DisplayMemberPath = "nameFull";

     

    xamComboEditorSample.ItemsProvider.ItemsSource = query;

    Hope this helps

    Vlad

    Developer Support Team