I am programmatically creating a DataGrid and need the row heights to be variable so that rows with multiple lines of text have a great height to accomodate the additional lines.
I tried setting the RowHeight property in code, but this requires a fixed value. If I leave RowHeight unset it just uses an arbitrary value that does not expand if the text doesn't fit.
I would also like to have my DataGrid contents to be scaleable, so if the DataGrid is resized the actual cell resize as well, including the font inside the cells. I could use a Viewbox for this, but I've had issues with the Viewbox as it will not grow to fit the text, it shirks/expands the text to fit in it.
Perhaps I need to walk through all of the rows and columns on a resize and set the height property manually.
Great answer to this problem from Tom - came in very useful just now. If you want to acheive this purely in Xaml without code behind, you can add the following property in your DataGrid declaration RowHeight="{x:Static sys:Double.NaN}"
To get the 'sys' namespace recognised here, you would have to addxmlns:sys="clr-namespace:System;assembly=mscorlib"
to the xmlns declarations at the top of your Xaml file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With