C# C和WPF列表视图和排序
在对列表视图排序时,为什么以后不能再次排序 列表框包含动态添加的复选框C# C和WPF列表视图和排序,c#,wpf,C#,Wpf,在对列表视图排序时,为什么以后不能再次排序 列表框包含动态添加的复选框 (XAML) <ListView Name="Main_List_View" /> (C#) //The Dictionary list is being populated before this loop is run Dictionary<string,string> list = new Dictionary<string,string>(); foreach(var item
(XAML)
<ListView Name="Main_List_View" />
(C#)
//The Dictionary list is being populated before this loop is run
Dictionary<string,string> list = new Dictionary<string,string>();
foreach(var item in list)
{
CheckBox box = new CheckBox();
box.Name = item.Key;
box.Content = item.Value;
Main_List_View.Items.Add(box);
}
现在,该列表在运行时成功按升序排序。
但是,只要我对同一个listview进行排序,并使用一个按钮进行降序,什么都没有发生,这可能是什么原因呢
(C#)
//Button event here
Main_List_View.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Descending));
在添加降序排序说明之前,请清除可用的排序说明
Main_List_View.Items.SortDescriptions.Clear();
Main_List_View.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Descending));
Main_List_View.Items.SortDescriptions.Clear();
Main_List_View.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Descending));