JohnM
JohnM

Reputation: 75

Click on a datagrid column header impossible

I created a datagrid with dataGridTemplateColumn and I can't use the click on header to sort anymore. Here is a sample of my code :

       <DataGrid.Columns>
            <DataGridTemplateColumn Header="action id" Width="Auto">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <Label Content="{Binding id}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

Do you have an idea of what is going wrong? Is this because of the use of a template that the default sort is desactivated?

Thanks,

J.

Upvotes: 2

Views: 1496

Answers (2)

blindmeis
blindmeis

Reputation: 22445

you should set the SortMemberPath property

<DataGridTemplateColumn SortMemberPath="id" Header="action id" Width="Auto">

Upvotes: 6

Rohit Vats
Rohit Vats

Reputation: 81243

Try setting the property CanUserSortColumn = true for your DataGridTemplateColumn.

Upvotes: 0

Related Questions