I'm trying to bind the tooltip of textblocks to the value the textblock text is bound to.
The following works for textblocks that apply this style:
<Style x:Key="GridCell" TargetType="{x:Type TextBlock}">
<Setter Property="ToolTip" Value="{Binding Converter={StaticResource CellToolTipConverter}}"/>
</Style>
<DataTemplate x:Key="GridCellContentTemplate">
<TextBlock Style="{StaticResource GridCell}"
Text="{Binding Converter=..."/>
</DataTemplate>
<xcdg:Column FieldName="FXRate" CellContentTemplate="{GridCellContentTemplate}" />
But for some strange reason, when I try to pass this style in as a resource to datagrid stat cells,
<Style x:Key="{x:Type xcdg:StatCell}" TargetType="{x:Type xcdg:StatCell}">
<Style.Resources>
<Style x:Key="{x:Type TextBlock}" TargetType="{x:Type TextBlock}">
<Setter Property="ToolTip" Value="{Binding Converter={StaticResource CellToolTipConverter}}"/>
</Style>
</Style.Resources>
</Style>
<xcdg:StatCell FieldName="Limit">
<TextBlock Text="{Binding Source={StaticResource Layers}, Path=StatLimit, Converter=..." />
</xcdg:StatCell>
As you can see, the tooltip is being bound to some DataTemplate rather than whatever the textbox text is bound to. From what I can tell though, there's no difference in these two, in fact the latter seems more straightforward.
Can anyone figure out why the second tooltip binding isn't working the way the first one is?
Note I can be sure that the binding is making its way though to the textbox in the cell, because if I change the binding to:
<Style x:Key="{x:Type xcdg:StatCell}" TargetType="{x:Type xcdg:StatCell}">
<Style.Resources>
<Style x:Key="{x:Type TextBlock}" TargetType="{x:Type TextBlock}">
<Setter Property="ToolTip" Value="{Binding Path=Text, RelativeSource={x:Static RelativeSource.Self}, Converter={StaticResource CellToolTipConverter}}"/>
</Style>
</Style.Resources>
</Style>
I get this:
But of course, I don't want the textblock text property, I want the raw value the textblock is bound to.
<TextBlock Style="{StaticResource GridCell}"/>
– Tejs<xcdg:StatCell FieldName="Limit"><TextBlock Style="{StaticResource GridCell}">
results in the tooltip that says "System.Windows.DataTemplate" – Alainx:Key
must be a simple string (ex:x:Key="{x:Type TextBlock}"
That looks odd to me. It may be nothing though (and it just that string value as the key). – Tejs