akgulebubekir / Maui.DataGrid

DataGrid component for Maui
MIT License
261 stars 54 forks source link

Drawing error when border size set to zero. #179

Open lendres opened 7 months ago

lendres commented 7 months ago

Describe the bug There appears to be a minor issue with the borders if the border size is set to zero.

To Reproduce Steps to reproduce the behavior:

  1. Using the sample, go to 'Settings'
  2. Set the 'Border Thickness' to zero (Click on the '-" button until it darkens).
  3. Close the settings and observe the vertical border between different columns. Resizing the window may be necessary to see the issue.
  4. Resizing the window causes the vertical border issue to appear, disappear, or move. There may be zero, one, or more than one vertical border.

Expected behavior When the border size is set to zero, no vertical borders should be visible.

Screenshots First example: image

After changing the size of the window, the bar has moved: image

Desktop (please complete the following information):

symbiogenesis commented 6 months ago

I had seen this before, at some point.

I think this is a windows-only bug in upstream MAUI or WinUI

We use a combination of background color and padding at the DataGridCell level to efficiently produce a border effect. Compared to the slow Border controls. I had tried using ColumnSpacing at the DataGridRow level but I think it had some problems.

Using an actual Border control wouldn't help, either, since apparently resizing Border controls on Windows is likewise problematic. https://github.com/dotnet/maui/issues/20407

The current approach of doing borders at the cell-level in general probably isn't ideal, because the widths are actually doubled. So if you want borders that have a width of 1, you would need to set BorderThickness to 0.5

Perhaps refactoring to using ColumnSpacing will work better today than in the past.

symbiogenesis commented 6 months ago

I can reproduce it but only if I resize to very specific widths. The initial width doesn't show it.

image

symbiogenesis commented 6 months ago

Just tried it. Using ColumnSpacing works but has the same issue.

https://github.com/akgulebubekir/Maui.DataGrid/pull/180

symbiogenesis commented 6 months ago

There was a bugfix in MAUI recently that may be related.

https://github.com/dotnet/maui/pull/21197