Sort a wpf datagrid programmatically

前端 未结 6 2407
攒了一身酷
攒了一身酷 2020-11-29 08:22

Is there a way to sort a WPF DataGrid programmaticaly ( for example, like if i clicked on my first column).

Is there a way to simuate this click ? Or a best way ?

6条回答
  •  既然无缘
    2020-11-29 08:46

    Fast & Easy way:

    dgv.Items.SortDescriptions.Clear();
    dgv.Items.SortDescriptions.Add(new SortDescription("ID", ListSortDirection.Descending));
    dgv.Items.Refresh();
    

提交回复
热议问题