【问题标题】:WPF dataGrid tool tip serviceWPF dataGrid 工具提示服务
【发布时间】:2013-07-18 00:19:43
【问题描述】:

所以我有一个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>

【问题讨论】:

    标签: wpf xaml wpf-controls tooltip wpfdatagrid


    【解决方案1】:

    请将此添加到您的资源中

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

    【讨论】:

    • 当我尝试加载数据网格时,setter 出现错误
    • 请您指出错误吗?它对我来说非常有效,没有任何错误。
    猜你喜欢
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 2014-12-10
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    相关资源
    最近更新 更多