WPF DataGrid 重写表头后,鼠标上移很耗CPU,如何解决?
如题,表头重写如下,主要实现表头换行:
<Style x:Key="style_dg_colHeder" TargetType="DataGridColumnHeader">
<Setter Property="FontSize" Value="12" />
<Setter Property="FontFamily" Value="Microsoft YaHei" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<DockPanel>
<TextBlock Text="{Binding}" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Center" />
</DockPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>