I have a WPF application which layout consists of 3 rows in a top level Grid.
I want the middle row to use up the space it needs (the maximum space it needs is limited but depends on the width of the window).
The bottom row shall use up the remaining space.
The tricky part is the top row.
Its size can vary depending on a button which toggles the visibility of a large part of the content. I want it to use at most 50% of the height but not more than it really needs.
The following XAML describes what I want to accomplish:
<Grid.RowDefinitions>
<!-- neither "1*" nor "Auto" fully meets my needs -->
<RowDefinition Height="Min(1*,Auto)"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="1*"></RowDefinition>
</Grid.RowDefinitions>
The rows are:
WrapPanelWrapPanelTextBox
if this is important.
If I understand it right, you could probably use
Autoand then bind theMaxHeightattribute to theHeightof theGrid. Maybe something like this:MaxHeightConverter.cs:
MyWindow.xaml:
Hope this helps.