0

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.

Amol Bavannavar
  • 2,062
  • 2
  • 15
  • 36

2 Answers2

0

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>
Muck
  • 11
  • 2
  • I know this way I can achieve it but I don't want to bind with its DataContext properties. I want this Template to work with all other DataGridCell too. Thank you for your effort's. – Amol Bavannavar Dec 11 '14 at 11:03
0

I tried this way and found solution.

<Style TargetType="DataGridCell">
    <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Content.Text}"/>
 </Style>
Amol Bavannavar
  • 2,062
  • 2
  • 15
  • 36