I made a template for a cell in a column of a wpf datagrid.
<DataGridTemplateColumn Header="R" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border Width="10" Height="10" BorderThickness="3">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="Green"/>
<Setter Property="BorderThickness" Value="3"/>
</Style>
</Border.Style>
<Rectangle Width="7" Height="7" Fill="Red"/>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Wpf inspector shows that the style is applied, but it is not visible. Why not?
If by
it is not visible
you mean that you don't see the border around yourRectangle
then it's because you didn't set Border.BorderBrush property.If changed like this, you'll see black border around your red Rectangle:
Green background you won't see because it is under
Rectangle
.