Disable sorting by auto-generated columns in DataGrid in WPF MVVM

I have a DataGrid in WPF with auto-generated columns.

How can I disable the sort function of all rows following the MVVM pattern?

<DataGrid AutoGenerateColumns="True" ItemsSource="{Binding MyList}" </DataGrid> 
+5
source share
1 answer

Set CanUserSortColumns="False" in the dataGrid, which will disable sorting for all columns.

 <DataGrid AutoGenerateColumns="True" ItemsSource="{Binding MyList}" CanUserSortColumns="False"> </DataGrid> 
+30
source

Source: https://habr.com/ru/post/1201801/


All Articles