I'd like to add a tooltip for particular field I've defined in my XamDataGrid's FieldLayout.Fields collection. The tooltip should be different for each cell in that column ... depending on what the data is. Preferably I'd like to databind the tooltip value to a property in the underlying data object, but it could be done in code as well.
This is what I currently tried:
<
igDP:Field Name="ActionCode" Label="Action Code" Width="150" ToolTip="{Binding Path=ActionCodeName}"/>
Of course, that just places a tooltip on the column header (and actually no text gets displayed, but that's probably a binding problem).
Hello,
I have been looking into this for you and in order to have a different ToolTip for each cell, I suggest you set the CellValuePreenter’s ToolTip through a style. You can use the FieldSettings’ CellValuePresenterStyle property to specify this for a specified field. If you would describe in more details how you get the data for the different ToolTips I might be able to further elaborate my answer.
Please let me know if you require any further assistance on the matter.
OK, I've tried modifying the CellValuePresenter for a particular field, but can't seem to get the data to show. I think it's a binding scope issue or something. Basically I need to bind 2 different properties to a couple properties in the DataItem of the record. I'm trying like this:
<igDP:Field Name="ActionCode" Label="Action Code" Width="150">
<igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Border BorderThickness="0,0,1,0" BorderBrush="#4C000000">
<eclp:EclpTextBlock HorizontalAlignment="Left" Text="{Binding Path=ActionCode, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}}" ToolTip="{Binding Path=ActionCodeName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
Hello Dustin,
I have been looking through your snippet and since “ActionCode” and “ActionCodeName” are not properties of the XamDataGrid I suppose you have provided them as its DataContext which means that this should wok if you change your binding paths like so:
Path=DataContext.ActionCode
and
Path=DataContext.ActionCodeName
If this doesn’t help I am going to need a test sample in order to figure out the bindings you need.
Also instead of retemplating the whole CellValuePresenter I suggest you only retemplate its ContentPresenter, in order to preserve the built-in functionality. You can do this by creating a setter for the ContentTemplate property instead of the Template property.
Please let me know if I can do anything else for you regarding this matter.
Does the DataContext you added in your code snippet point to the CELL's data context, or the data context of the record? I want to access the data context of the record, and use a couple properties that are available in the data object assigned to the row (record) ... is that possible?
Hi,
In my previous response I was taking into consideration the binding you had created that pointed to the XamDataGrid and I thought that you have a separate property in your view model that you wanted to reference. By default the CellValuePresenter has a its containing Record as DataContext so if you want to access a property from the data object you are using you can create a style like this one:
<Style TargetType="{x:Type igDP:CellValuePresenter}" >
<Setter Property="Template" >
<TextBlock Foreground="Red" Text="{Binding Path=DataItem.Age}" />
And as I suggested last time, in order not to lose the built-in functionality make a setter for the ContentTemlate:
<Setter Property="ContentTemplate" >
<DataTemplate>
<StackPanel>
<TextBlock Foreground="Green"
Text="{Binding RelativeSource={RelativeSource
AncestorType={x:Type igDP:CellValuePresenter}},
Path=Value}" />
<TextBlock Foreground="YellowGreen"
Path=DataContext.DataItem.Points}" />
</StackPanel>
</DataTemplate>
I have also attached a sample project (Grid_CellValuePresenter_Binding.zip) so you can see the difference.
Please let me know if I can assist you any further on this matter.