改变数据源的排序很简单,可以参考下面的代码
- bool sqe = true;
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- if(sqe)
- combo.ItemsSource = (combo.ItemsSource as List<string>).OrderBy(t => t).ToList();
- else
- combo.ItemsSource = (combo.ItemsSource as List<string>).OrderByDescending(t => t).ToList();
- sqe = !sqe;
- }
复制代码 |