Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF datagrid row horizontal alignment issue

I'm using a DataGrid in a form to show a list of (userID, name, balances, etc.). There is a very strange issue with it, at the beginning of some rows (one out of very twenty rows) there is a small white space that is causing that row to be misaligned. The white space is like a little rectangle that is placed right before the first cell of the row. I reviewed my styles and everything but cannot figure out why this is happening. This happens only when I programmatically scroll my DataGrid, after the scroll is done the white spaces appear.

What makes things worse is that the white space is resizable! and when I resize it with my mouse it screws up the grid. I really don't want to ship something like this out.

I don't have much experience in WPF, I would really appreciate it if someone could give me some idea about where to look. Thanks.


Edit: Here is the screenshot:

enter image description here

like image 621
DeveloperInToronto Avatar asked Nov 19 '12 18:11

DeveloperInToronto


1 Answers

This issue is caused by row headers being "shown" for some random rows.

I don't know why it happens, but fortunately the fix is simple.

If you set RowHeaderWidth="0" on the DataGrid, the behavior should be as expected.

For some reason the row headers are still making an appearance even though HeadersVisibility is set to Column.

like image 115
Peter Hansen Avatar answered Nov 10 '22 04:11

Peter Hansen