【发布时间】:2015-05-14 17:40:33
【问题描述】:
我有一个列表框:
<ListBox Name="LbFrequentColumnItems" Grid.Row="1" MinHeight="0"></ListBox>
我在上面的列表框中添加了许多图像按钮,如下所示:
ImageButton b = new ImageButton();
b.Content = d.DisplayName;
b.Click += new RoutedEventHandler(OptionalColumnItems_Click);
LbFrequentColumnItems.Items.Add(b);
单击按钮时,我需要按内容排序显示所有图像按钮。
我可以通过复制列表中的所有内容然后排序并再次添加按钮来做到这一点。
但是listbox有没有直接的方法或者方法来执行呢?
我尝试了以下方法,但由于我没有任何属性绑定,因此无法正常工作:
LbFrequentColumnItems
.Items
.SortDescriptions
.Add(
new System.ComponentModel.SortDescription("",
System.ComponentModel.ListSortDirection.Ascending));
【问题讨论】:
标签: c# wpf sorting listbox controls