WPF 给DataGridTextColumn统一加上ToolTip

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

Xml代码  收藏代码
    1. <DataGrid.CellStyle>   
    2.     <Style TargetType="DataGridCell">   
    3.         <Setter Property="ToolTipService.ToolTip"   
    4.             Value="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content.Text}" />   
    5.     </Style>   
    6. </DataGrid.CellStyle>   
posted @ 2015-06-26 15:40  风中的萤火虫  阅读(277)  评论(0)    收藏  举报