DataGridCell Template to display Tooltip

472 views Asked by At

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.

2

There are 2 answers

0
Amol Bavannavar On BEST ANSWER

I tried this way and found solution.

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

I use for this only a style. A template is not required.

<Style TargetType="DataGridCell">
    <Setter Property="ToolTip">
        <Setter.Value>
            <ToolTip Content="{Binding Path=Day}"/>
        </Setter.Value>
    </Setter>
</Style>