I'm trying to set a tooltip for a row in a XamDataGrid. Can be done?I want it when the mouse moves over the record tooltips becomes visible. Can somebody help me? Thanks
Hello,
If you want to see tooltips for each particular cell, you can do this via styles.
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=Value}"></Setter>
Basically, all that I did was create a style that targets the CellValuePresenter (The presenter that displays the cell data) and set the tooltip property. I used a binding to the Value property off of the CellValuePresenter which is the value of the cell itself.
Also, I noticed that you mentioned record and not cell. If you want this tooltip to appear for the whole record, you will have to do something very similar and target the DataRecordCellArea instead.
<Style TargetType="{x:Type igDP:DataRecordCellArea}">
Then, you can initialize the setter and give it any value that you want.
if you really want to get fancy, you can create your own ToolTip object and bind that to all three values of the record. In the snippet below, I assigned the ToolTip of the DataRecordCellArea to the ToolTip object right below it. In there, I used the PlacementTarget property to set the DataContext of the Tooltip and then used simple binding to get the values from the record(PlacementTarget) to place in the TextBlocks.
<Setter Property="ToolTip" Value="{StaticResource SpecialToolTip}">
</Setter>
<ToolTip x:Key="SpecialToolTip" DataContext="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget}">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=Record.Cells[0].Value}"></TextBlock>
<TextBlock Text="{Binding Path=Record.Cells[1].Value}"></TextBlock>
<TextBlock Text="{Binding Path=Record.Cells[2].Value}"></TextBlock>
</StackPanel>
</ToolTip>
Hope this helps.
I was able to adorn selected column cells with the tool tip by specifying styles and setter for ToolTip property. It works well, but it also always displays empty narrow tooltip rectangle even if the cell has no data.
I thought one should use a IValueConverter derived class to conditionally display the tooltip only for teh vells with the data. I am having a difficulties though to use my converter in xaml as I have a FieldLayout xaml file with all fields defs (and added styles for tooltip).
I wonder if there is a simplier solution for conditionally displaying tooltip on cells in XamDataGrid?
Thanks a lot in advance
Great post, Steve!
Hy Steve.
Do you know is it possible to have the tooltip for the header of a column for the grid?
I tryed to use ToolTipService but it's not working.
<my:Field Name="Title" ToolTipService.ToolTip="help" Label="{Binding Path=headerTitle, Source={StaticResource resStaticData}, Mode=OneWay}">
Thanks very much.
Nico