I'm trying to implement a behavior so a tooltip is shown when the text in a cell is longer than what is visible. I have found a stackoverflow solution for this here: https://stackoverflow.com/questions/22709715/automatic-tooltip-when-text-is-trimmed-in-datagrid
The issue is that I'm not able to get the background style for this cell when the row is selected or hovered. It has the alternating row background. But it will not change background when hovered or selected. I have tried to create my own style triggers, but I'm not able to update Background with these either. Foreground and other properties however work fine.
Any idea? below is my code sample.
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" Width="*">
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Static themes:DataGridResourceKeys.DataGridCellStyleKey}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Text}" TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip>
<ToolTip Visibility="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget, Converter={StaticResource TrimToVisConverter}}">
<ToolTip.Content>
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Text}"/>
</ToolTip.Content>
</ToolTip>
</TextBlock.ToolTip>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Blue"/>
<Setter Property="Foreground" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>