A WPF Grid control with 3 row and 3 columns. The Height of the Row in question is set to Auto. In the first two cells I have two controls with dynamic heights. In the third cell, I have another control I want to be automatically set to stretch within the Grid cell. I have tried VerticalAlignment="Stretch"
, but that simply sets Grid Row Height equal to control's height. What are my options here?
Not sure what kind of control you are using in Cell 3, but most of the WPF controls will automatically stretch to fit inside the Grid cell. The row height of your grid will be set by the height of the controls in Cells 1 and 2.
If you are using some kind of custom control where the default behavior for height is different, you can set Height="Auto"
.
If that doesn't work either, you can do a data binding to get the actual height of the control in either cell 1 or 2. Set the Height
property of your control in Cell 3 to the following:
Height="{Binding ActualHeight, ElementName=MyControlNameFromCell1, Mode=OneWay}"
EDIT
Another way that might be more robust is to do a data binding for the Height of the row. So instead of using "Auto"
for the height of the row, use the data binding shown above.
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