Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C和WPF列表视图和排序_C#_Wpf - Fatal编程技术网

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));