AxdorphCoder
AxdorphCoder

Reputation: 1222

Disable sorting on autogenerated columns in DataGrid

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>

Upvotes: 13

Views: 17015

Answers (1)

Rohit Vats
Rohit Vats

Reputation: 81253

Set CanUserSortColumns="False" on dataGrid which will disable sorting for all columns.

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

Upvotes: 50

Related Questions