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
I wanted the tooltip not to show for the filter row of the grid and did it this way. Just sharing my code.
<Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="ToolTip" Value="{StaticResource MyToolTip}" /> <Style.Triggers> <DataTrigger Binding="{Binding RecordType}" Value="FilterRecord"> <Setter Property="ToolTip" Value="{x:Null}" /> </DataTrigger> </Style.Triggers></Style>
Hello,
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
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
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,