0

I have a datagrid with multiple columns. I want to display a tooltip when user hovers the mouse on the cell of one of those columns. Here is the code that I have tried:

<DataGridTextColumn Binding="{Binding PackageName}"  MinWidth="250" IsReadOnly="True" ElementStyle="{StaticResource ResourceKey=StyleDataGridText}">
    <DataGridTextColumn.HeaderStyle>
        <Style TargetType="DataGridColumnHeader">
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="Background" Value="#E3E3E3"/>
        </Style>
    </DataGridTextColumn.HeaderStyle>
    <DataGridTextColumn.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="ToolTip" Value="{Binding Info}" />
        </Style>
    </DataGridTextColumn.CellStyle>
    <DataGridTextColumn.Header>
        <DockPanel>
            <TextBlock Text="Package Name"/>
            <Image x:Name="SortPackageNameImg" Source="{StaticResource SortupImg}" Width="10" Height="10" Margin="10,0,0,0"></Image>
            <Button Name="PackageNameFilterBtn" Click="PackageNameFilter_Click" HorizontalAlignment="Right" Margin="0,0,10,0">
                <Button.Template>
                    <ControlTemplate>
                        <Image Source="/Resources/filter.png" Width="10" Height="10"/>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </DockPanel>
    </DataGridTextColumn.Header>
</DataGridTextColumn>

But this is not working. Is there anything I need to change to fix this?

mm8
  • 163,881
  • 10
  • 57
  • 88
The King
  • 833
  • 1
  • 15
  • 41
  • 1
    check answer here : http://stackoverflow.com/questions/1164288/how-do-i-add-a-tooltip-to-a-datagridtextcolumn – Naresh Ravlani Apr 06 '17 at 09:15
  • I have tried the same but it doesn't work for me. Looks like I am missing something. – The King Apr 06 '17 at 09:17
  • Did you try @MarkGladding's answer? I think that should work for you. If it's not working, let me know – Naresh Ravlani Apr 06 '17 at 09:19
  • 1
    What does "not working" mean exactly? Does it work if you set the Value of the ToolTip property to a fixed value like "test"? And how is your "StyleDataGridText" defined? – mm8 Apr 06 '17 at 09:30
  • What is in the style StyleDataGridText? also, what are properties of the DataGrid itself? For example, if IsHitTestVisible is set to false on the DataGrid, the tooltip will indeed not work. – Arie Apr 06 '17 at 09:33
  • Sorry, It was a type. Binding Info field should have been Binding ReleaseInfo. It fixed. – The King Apr 06 '17 at 09:53

0 Answers0