Search code examples
c#wpftooltipcontentpresenterdatagridcell

DataGridCell Template to display Tooltip


I want to display tooltip on DataGridCell. So far I tried with the following way. But the problem is when I hover on DataGridCell, whole DataGridCell content's gets disappered.

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

Can any one help me..

Thanks in advance.


Solution

  • I tried this way and found solution.

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