Making a DataGrid Column Header sortable in WPF using C#
In your DataGridTemplateColumn
you have SortMemberPath set to "". If you set this to an actual property on the item (say, CompleteDate), you should be able to sort. You can also set CanUserSort="true"
or CanUserSort="false"
on selected columns.
SortMemberPath gives the property to sort on when the user attempts a sort. If this isn't set, then the grid doesn't know how to sort that column ( it does not use the text in the column)
<my:DataGridTemplateColumn SortMemberPath="CompleteDate" Header="Complete Date" CanUserSort="true"> <my:DataGridTemplateColumn.CellTemplate > <DataTemplate> <TextBlock> <TextBlock.Text> <Binding Path="CompleteDate" ConverterCulture="en-GB" StringFormat="{}{0:MM/dd/yyyy}"/> </TextBlock.Text> </TextBlock> </DataTemplate> </my:DataGridTemplateColumn.CellTemplate> </my:DataGridTemplateColumn>