I’m using the WPF DataGrid and have it set to place a red border around any row that the user modifies. It works well, however when the border appears all the cells inside that row get pushed over a pixel or two. In other words a cell’s left and right border no longer lines up with the one above or below it, so it looks weird.
Here’s the code I’m using to get the red border to appear OnEdit (Note: IsDirty is a property on my bound object that’s set when a value gets modified):
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDirty}" Value="true">
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="BorderThickness" Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>
What can I add so that I can modify the red border margins so that it won’t interfere with the cells’ borders?
Thanks
The Visual Tree looks something like this
When you change the
BorderThicknessof theBorderyou could compensate this by adding negativeMargin.Leftto theDataGridCellsPresenterat the same time. Not the prettiest solution but it works