I had some serious trouble with this (bug?) today, so I'll share what I tried and what almost worked... (And hope that someone knows an actual fix)
In my case the bug only appeared when there were 10 or more rows. Out of the rows, ten first rows would in some cases have too small height for the contents. (I first thought that the nine items were drawn on top of each other, which was stupid of me.) There are quite many columns, so there's a scrollbar. Clicking on the scrollbar resizes the heights to proper values.
Some things that in my experience do not work:
- Changing virtualization settings had no effect.
- InvalidateVisual() and InvalidateArrange() don't work. Tried both datagrid and its parent.
- Changing the height of datagrid did not work (although I'm not quite happy with my tests here)
- Forcing the datatemplates of the cells to a specific size did not have an effect.
- Placing the datagrid inside a scrollviewer (so that the datagrid would have all the space it could ever need...) did not work.
However:
The one thing (I found) that the datagrid seems to respect is MinRowHeight-setting, so now I've got there a moronic value and I'm hoping that this won't cause problems later on when the datatemplates are modified.