Pre-sorting a DataGrid in WPF

后端 未结 5 1916
野性不改
野性不改 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:50

    When you see ItemsSource doesn't support CollectionViewSource exception then you can set the DataContext of DataGrid as 'MyItemsViewSource' and ItemsSource as {Binding} like this:

    
    
    

提交回复
热议问题