I have a DataGrid in WPF with autogenerated columns.
How can I disable sorting functionality of all the rows following the MVVM pattern?
<DataGrid AutoGenerateColumns="True"
ItemsSource="{Binding MyList}"
</DataGrid>
Disabling Column Sorting | ComponentOne DataGrid for WPF and Silverlight. By default end users can sort columns in the grid at run time. For more information, see Sorting Columns. If you choose, however, you can disable the column sorting feature by setting the CanUserSort property to False.
WPF DataGrid (SfDataGrid) allows you to sort the data against one or more columns either in ascending or descending order. The sorting can be performed by clicking a column header. You can enable/disable the sorting for all the columns in DataGrid by using DataGrid. AllowSorting property.
RadGridView supports column reordering and it can be done by the user in run-time. The user can drag the desired column's header at the desired position among the other headers and drop it there.
A DataGrid is a control that displays data in a customizable grid. It provides a flexible way to display a collection of data in rows and columns. The hierarchical inheritance of DataGrid class is as follows −
Set CanUserSortColumns="False"
on dataGrid which will disable sorting for all columns.
<DataGrid AutoGenerateColumns="True"
ItemsSource="{Binding MyList}"
CanUserSortColumns="False">
</DataGrid>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With