wpf中ToolTip实现

时间:2022-02-18 23:19:51
定义样式:
<UserControl.Resources>
<Style TargetType="DataGridCell" BasedOn="{StaticResource DefaultDataGridCellStyle}" x:Key="ToolTipsStyle">
<Setter Property="ToolTipService.ToolTip" Value="{Binding Remark}" />
</Style>
</UserControl.Resources> 然后再dataGrid中的列定义使用:
CellStyle="{StaticResource ToolTipsStyle}" 注意这里继承了DefaultDataGridCellStyle