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
How to set the tooltip from Code. I am facing problem in setting tooltip from code. last style is getting appl;ied to the column header.
Thanks,
Vinod
Hello Vinod,
If you want to set the tooltip from code, you can do the following.
Style s = new Style(typeof(LabelPresenter));s.Setters.Add(new Setter(ToolTipProperty,"MyToolTip"));this.XamDataGrid1.FieldLayouts[0].Fields[0].Settings.LabelPresenterStyle = s;
Of course, if you want to have the value be bound to the ToolTipService.ToolTip you will have to something similar to this.
Binding b = new Binding();b.Source = this.XamDataGrid1.FieldLayouts[0].Fields[0];b.Path = new PropertyPath(ToolTipService.ToolTipProperty);//b.RelativeSource = new RelativeSource(RelativeSourceMode.Self);//b.Path = new PropertyPath("Field.(ToolTipService.ToolTip)"); Style s = new Style(typeof(LabelPresenter));s.Setters.Add(new Setter(ToolTipProperty, b));this.XamDataGrid1.FieldLayouts[0].Fields[0].Settings.LabelPresenterStyle = s;
The binding can't be done exactly like it is done in xaml though. There seems to be a difference in how the xaml parser interprets Attached Properties as compared to the C# code. So you cant set the relativeSource to Self and the Path to Field.(ToolTipService.ToolTip) which I have commented out for you. You must set the source to the actual field and then the path to the ToolTipServices.ToolTipProperty. This should work.
Good Luck,