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.
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
Nico,
You can specify a tooltip on a field label by setting the FieldSetting's LabelPresenterStyle like so:
<igDP:Field Name="Greetings"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.LabelPresenterStyle> <Style TargetType="{x:Type igDP:LabelPresenter}"> <Setter Property="ToolTip" Value="Hello, World!" /> </Style> </igDP:FieldSettings.LabelPresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings></igDP:Field>
Josh
Hy Josh.
Thanks so very much for the answer. This is a solution but I will have to define this style for every field.
Is it possible to have a generic one and bind the value for the ToolTip to somethig? I meen something like this: have the style define for the LabelPresenter, a setter for the ToolTip property and the value of the ToolTip will be binded to a property of the field (maybe the Tag property). In this way, it will be enough to set the "Tag" peoperty of the Field and it will know that this will be the value for the ToolTip.
<Style x:Key="GridHeader" TargetType="{x:Type dataPresenter:LabelPresenter}"> <Setter Property="ToolTip" Value="{some property of the Field to bind it to, maybe the Tag of the Field}"/></Style>
<igDP:Field Name="Greetings" Tag="Some tooltip"/>
I tried this but I was not able to make it work. I used also the Ancestor but it was the same. Please if you have questions let me know and I will try to explain better what I want to do. Thanks again.
Good question, Nico. Here's the solution I came up with for you:
<igDP:XamDataGrid x:Name="xamDG" DataSource="{Binding}" > <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:LabelPresenter}"> <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Field.(ToolTipService.ToolTip)}" /> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="Name" ToolTipService.ToolTip="The person's name" /> <igDP:Field Name="Age" ToolTipService.ToolTip="The person's age" /> <igDP:Field Name="Status" ToolTipService.ToolTip="The person's marital status" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts></igDP:XamDataGrid>
I do not think this will be possible with an unbound field or a bound field. There is no way to get back to the DataItem or even the Record for that matter when in the Label Presenter.
Sorry for any inconvenience that this may cause.
This is soclose to what I'm looking for. The one thing that it's missing is that I'm using an UnboundField that has BindingPath="Name". But in the tooltip, I want to bind to a property named "Age", rather than the value of Name or a hardcoded value (such as "The person's age"). I have not been able to figure out a way to access the Record.DataItem from within the UnboundField itself. I can't get the DataContext or pretty much any value other than the one that the BindingPath is set to.
I can do it if I apply a template to each field but I'd prefer to not HAVE to do it that way. Any ideas?
Fred
This work's perfect. Thanks so very much.