Reputation: 571
I've got a dynamic datagrid in WPF that I'm trying to add a slightly thicker black left hand border to for the first column in a group.
The code I have to do this is:
DeltaStyle.Setters.Add(new Setter(GridCell.BorderBrushProperty, new SolidColorBrush(Colors.Black)));
DeltaStyle.Setters.Add(new Setter(GridCell.BorderThicknessProperty, new Thickness(1,0.5,0.5,0.5)));
Where DeltaStyle is the columns style that is used in its creation.
When it displays it looks like this:
The formatted column is the one with the header 'b.%F'
As you can see the other borders seem to have changed colour and are offset slightly. The black border on the left also looks a bit offset. Does anyone know why this is?
Rob
Upvotes: 0
Views: 37
Reputation: 2947
The default border of the DatagridCell has thickness equal to 0, those separator gray lines are probably part of the column itself. If you set the thickness to 1, then you have the result experienced.
To solve your case something like this could work, set a negative margin for the cell so it can overlay the separators:
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Margin" Value="-1,0,0,0" />
<Setter Property="BorderThickness" Value="1,0,0,0" />
<Setter Property="BorderBrush" Value="Black" />
</Style>
Upvotes: 1