countrymeister
asked on
How to orderby items in a silverlight combo box
I have a generic list which contains an object T.
This same list is used to bind multiple combo boxes on a silverlight page.
After I bind the combobox to this List source, I would like to order the Items in the Combobox accordingly.
Please not that I do not want to sort or order the List<T>, because this is used to bind multiple combo boxes
I would like to try something like this for my comboboxes
cbDesc.Items.OrderBy(???);
Here is my code
List<T> genericList = getData();
cbDesc.ItemsSource = genericList
cbDesc.DisplayMemberPath ="Name"
cbDesc.SelectedValuePath = "Name"
cbDesc.Items.OrderBy(???);
cbRegion.ItemsSource = genericList
cbRegion.DisplayMemberPath ="Region"
cbRegion.SelectedValuePath = "Region"
cbProduct.ItemsSource = genericList
cbProduct.DisplayMemberPat h ="Product"
cbProduct.SelectedValuePat h = "Product"
This same list is used to bind multiple combo boxes on a silverlight page.
After I bind the combobox to this List source, I would like to order the Items in the Combobox accordingly.
Please not that I do not want to sort or order the List<T>, because this is used to bind multiple combo boxes
I would like to try something like this for my comboboxes
cbDesc.Items.OrderBy(???);
Here is my code
List<T> genericList = getData();
cbDesc.ItemsSource = genericList
cbDesc.DisplayMemberPath ="Name"
cbDesc.SelectedValuePath = "Name"
cbDesc.Items.OrderBy(???);
cbRegion.ItemsSource = genericList
cbRegion.DisplayMemberPath
cbRegion.SelectedValuePath
cbProduct.ItemsSource = genericList
cbProduct.DisplayMemberPat
cbProduct.SelectedValuePat
ASKER
I do not see the avaialble properties when I do
cbDesc.ItemsSource = cbDesc.Items.OrderBy(item => item.Name);
All I see when I type item. is Equals, GetType, ToString(), GetHasCode.
I do not see any of the properties such as Name, Region, Product
My xaml for the combobox is
<ComboBox Height="20" HorizontalAlignment="Left" Margin="155,19,0,0" Name="cbDesc" VerticalAlignment="Top" MinWidth="349" SelectionChanged="cbDesc_S electionCh anged" MaxDropDownHeight="200" />
cbDesc.ItemsSource = cbDesc.Items.OrderBy(item => item.Name);
All I see when I type item. is Equals, GetType, ToString(), GetHasCode.
I do not see any of the properties such as Name, Region, Product
My xaml for the combobox is
<ComboBox Height="20" HorizontalAlignment="Left"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window