WPF dataGrid工具提示服务

时间:2013-07-18 21:01:38

标签: wpf xaml wpf-controls tooltip wpfdatagrid

所以我有一个DataGrid,我希望能够使用ToolTip服务显示鼠标所在的单元格中的数据。有人能告诉我我做错了什么。非常感谢。

这是我的DataGrid

<DataGrid Name="dgData" CanUserAddRows="False" 
                        Style="{DynamicResource DataGridRow}" 
                        AutoGenerateColumns="False"
                        CanUserReorderColumns="False"
                        EnableColumnVirtualization="True" />

以下是我尝试过的内容,但是当我添加此内容时,我的应用不会加载DataGrid

<Style TargetType="{x:Type DataGrid}">
    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Value}" />
</Style>

1 个答案:

答案 0 :(得分:2)

请在您的资源中添加

<Style TargetType="{x:Type DataGridCell}">
    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content.Text}" />
</Style>
相关问题