Pre-sorting a DataGrid in WPF

后端 未结 5 1918
野性不改
野性不改 2020-12-06 04:15

I have a DataGrid in WPF app with several columns, including a Name column. If the users switches to a particular view, I want the data to be pre-sorted by Name

5条回答
  •  囚心锁ツ
    2020-12-06 04:55

    I know this is an old post but in addition to Drew Marsh's answer and in response to DanM's issue with the column header's arrows not appearing... You need to add the SortDirection property to the DataGridColumn:

    
    

    I posted a question about this and found the answer a few days later:

    ColumnHeader arrows not reflected when sorting a DataGrid in XAML

提交回复
热议问题