Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent border color rendering with black Background and BorderBrush. #9107

Open
TamilarasanGunasekaran opened this issue May 15, 2024 · 3 comments
Labels
Investigate Requires further investigation by the WPF team.

Comments

@TamilarasanGunasekaran
Copy link

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

@miloush
Copy link
Contributor

miloush commented May 15, 2024

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).

@Kuldeep-MS Kuldeep-MS added the Investigate Requires further investigation by the WPF team. label May 17, 2024
@huiliuss
Copy link

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.

@miloush
Copy link
Contributor

miloush commented May 21, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

4 participants