我想对SelectionName应用OrderBy Ascending,通过对radcombobox中的项目进行排序
dropDown.Items.AddRange(items.Select(x => new RadComboBoxItem(x.SelectionName, x.SelectionValue)).ToArray());
最佳答案
dropDown.Items.AddRange(items
.OrderBy(x => x.SelectionName)
.Select(x => new RadComboBoxItem(x.SelectionName, x.SelectionValue))
.ToArray());
如您所愿,您希望按其他值排序,可以使用
.ThenBy(x => x.Value)
。就你而言
dropDown.Items.AddRange(items
.OrderBy(x => x.SelectionName)
.ThenBy(x => x.SortOrder)
.Select(x => new RadComboBoxItem(x.SelectionName, x.SelectionValue))
.ToArray());