我有一个带有一个DataGridTemplateColumn的WPF Toolkit DataGrid。我已经在grid属性中指定了我希望所有列都是可排序的,但是DataGridTemplateColumn不允许这样做。所有其他列均允许排序。我什至尝试将该列的CanUserSort显式设置为true,但是没有运气。甚至可以对模板列进行排序吗?我提供了适用于所有列的自定义排序器,但标题不允许单击排序。
<Controls:DataGrid ItemsSource="{Binding Events}" AutoGenerateColumns="False"
CanUserSortColumns="True"
CanUserReorderColumns="False"
Sorting="DataGrid_Sorting"
x:Name="EventsGrid">
<Controls:DataGrid.Columns>
<Controls:DataGridTemplateColumn Header="Type" Width="42" CanUserResize="False">
<Controls:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding EventTypeImage, Mode=OneWay}" HorizontalAlignment="Center" Width="16"/>
</DataTemplate>
</Controls:DataGridTemplateColumn.CellTemplate>
</Controls:DataGridTemplateColumn>
<Controls:DataGridTextColumn Header="Source"
Binding="{Binding Source, Mode=OneWay}" />
<Controls:DataGridTextColumn Header="Details" MinWidth="175"
Binding="{Binding Details, Mode=OneWay}" />
<Controls:DataGridTextColumn Header="Timestamp" MinWidth="175"
Binding="{Binding Timestamp, Mode=OneWay}"
IsReadOnly="True"/>
</Controls:DataGrid.Columns>
</Controls:DataGrid>