Persist sorting from DataGrid to ItemsSource collection
问题 I have a DataGrid and I'm trying to do the Sort thing the most straightforward way: by clicking on the header of each column. This is working great on the View ( in the MVVM context ), but I want to sort the underlying ViewModel collection ( ObservableCollection ) too. Any suggestions on how to implement the source collection? 回答1: Bind the grid to a ListCollectionView , initialised with the ObservableCollection . The grid will use your pre-created ICollectionView instead of creating it's own