DataGrid中DataGridTemplateColumn的列默认是不能支持点击列头实现排序的,需要自己添加一些属性,如下面的代码,需要添加CanUserSort="True",SortMemberPath="你需要排序的列绑定的字段"
<DataGridTemplateColumn CanUserSort="True" SortMemberPath="Jiaoyanzhuangtai" Width="8*"
Header="状态" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Name="checkStatus" Text="{Binding Jiaoyanzhuangtai,Converter={StaticResource checkStatusConvert}}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="18"/>
<DataTemplate.Triggers>
<DataTrigger Value="1" Binding="{Binding Jiaoyanzhuangtai}">
<Setter TargetName="checkStatus" Property="Foreground" Value="Green" />
<Setter TargetName="checkStatus" Property="FontSize" Value="25px" />
<Setter TargetName="checkStatus" Property="FontWeight" Value="Bold" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>