wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Inconsistent border color rendering with black Background and BorderBrush.

Open TamilarasanGunasekaran opened this issue 1 year ago • 1 comments

Description

When setting both the Background and BorderBrush colors to black within a border element, an unexpected behavior occurs where an inner border in gray appears only on the top and bottom sides. This inconsistency in border color rendering contradicts the expected behavior and may lead to visual discrepancies in UI design.

Reproduction Steps

  • Download the sample attached.
  • Run the sample.
  • Observe the presence of the gray border color.

Issue Screenshot:

image

WPFDemo.zip

Expected behavior

The gray border color should not be displayed.

Actual behavior

The gray border color is displayed.

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

TamilarasanGunasekaran avatar May 15 '24 10:05 TamilarasanGunasekaran

Note that this is not "gray border", it is the background color peeking through space between the square's border and square's background. If you use SnapsToDevicePixels="True", this reproduces in a stable way with DPI 125%: image

I agree that should certainly not happen, at least not with this property set.

As a workaround, you can use UseLayoutRounding="true" (e.g. on the Grid) (or ensure the background behind the square is of matching color if possible).

miloush avatar May 15 '24 16:05 miloush

Hi, miloush's solution is great.


<Grid VerticalAlignment="Center" HorizontalAlignment="Center" SnapsToDevicePixels="True">

...

</Grid>

 

Have you checked the solution? If you still have issues please describe in more detail.

huiliuss avatar May 21 '24 06:05 huiliuss

@huiliuss It is not as much as solution as a workaround. Also as I showed above, SnapsToDevicePixels is not enough, which is potentially a bug.

miloush avatar May 21 '24 08:05 miloush