DataGridTemplateColumn & Sort

Mar 15, 2009 at 12:33 PM

In Vincent Sibal's V1 compatible (january 2009) "DataGridCTPSample"  (*), in the file "DataGridBasicSample_Demo2.xaml", I duplicated the column "Last Name" as follows :

                <dg:DataGridTextColumn Width="Auto" Header="Last Name" Binding="{Binding Path=LastName}" />
                <dg:DataGridTemplateColumn Width="Auto" Header="Last Name" CanUserSort="True">
                            <TextBlock Text="{Binding Path=LastName}"/>

Outcome : the first column "Last Name" accepts "sort" (click on header), the second one apparently does not. Any reason ?



(*) ZIP attached to

Mar 16, 2009 at 2:22 AM
For DataGridTemplateColumn you need to set the SortMemberPath DP explicitly.
Mar 16, 2009 at 7:42 AM

The following works indeed : SortMemberPath="LastName" with CanUserSort="True" being superfluous.

Vincent, thanks,