akgulebubekir / Maui.DataGrid

DataGrid component for Maui
MIT License
260 stars 53 forks source link

RowsBackgroundColorPalette does not always get reapplied after sorting. #164

Closed chrigi28 closed 8 months ago

chrigi28 commented 8 months ago

Describe the bug When sorting by a column the RowsBackgroundColorPalette does not always get reapplied, sometimes it does sometimes not. Couldn't find a proper cause. But its 100% reproduceable when sorting the provided example by Streak

To Reproduce Steps to reproduce the behavior:

  1. Go run the sample Project
  2. Disable Pagination (for clearer result)
  3. Sort by Streak
  4. See error background colors of row

Expected behavior The RowsBackgroundColorPalette should be reapplied after sorting to be bright / dark / bright / dark ....

Screenshots image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Sorting by other columns for example Won does sometimes the same by clicking and sorting multiple by Won it does sometimes fix it.

symbiogenesis commented 8 months ago

I was able to reproduce this only when disabling pagination, and only on the Streak column. Very interesting. Will look at it.

symbiogenesis commented 8 months ago

This was just an issue in the Sample code with the IComparable implementation on the Streak class. I have made it more robust.

Try the latest main branch now

symbiogenesis commented 8 months ago

When using any fancy IComparable logic or duplicate list items, remember that internally C# does index lookups by reference.