I am trying to control the background of a DataGrid cell in a column subject to its value. Unfortunately, I get something like this:

Which is not very aesthetically pleasing, I would like the whole cell to be in a different color, and not just part of the text. Here is the piece of code:
<DataGridTextColumn
Binding="{Binding Path=PrivateMemorySize, StringFormat='#,##0'}"
Header="Memory Size" >
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="HorizontalAlignment" Value="Right" />
<Style.Triggers>
<DataTrigger Binding="{Binding Path=PrivateMemorySize,
Converter={StaticResource isLarge},
ConverterParameter=20000000}" Value="true">
<Setter Property="Background" Value="Yellow" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
( isLarge- this is just a converter that returns truewhen the cell value is greater than the parameter)
If I define a style for the DataGridCell target, the result will be the same.
Any ideas what could be wrong? I do not use anything unusual, just the default DataGrid (which in this example is associated with CLR objects to populate the table).
source
share