首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

WPF 给DataGridTextColumn统一加下ToolTip

2012-12-25 
WPF 给DataGridTextColumn统一加上ToolTip我发现WPF中DataGridTextColumn直接设置它的ToolTipService.Tool

WPF 给DataGridTextColumn统一加上ToolTip
我发现WPF中DataGridTextColumn直接设置它的ToolTipService.Tooltip并不好使,当然可以在这个列的CellStyle中再设置ToolTipService.Tooltip的值,这是管用的。但是当列比较多的时候,这样一一设置比较麻烦。下面介绍一个统一的设置方法,在DataGrid中统一设置CellStyle

<DataGrid.CellStyle>     <Style TargetType="DataGridCell">         <Setter Property="ToolTipService.ToolTip"             Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content.Text}" />     </Style> </DataGrid.CellStyle> 

热点排行