WPF Grid Row / Column Sizing in Proportion to DesiredSize?
- by sinibar
I have two user controls arranged vertically in a grid, both of which can expand to be taller than the grid can accommodate. I've put them in each in a scrollviewer which functionally works. What I want though is to give them them space in proportion to the amount that they want at run time.
So if there's 500 height available, the upper control wants 400 and the lower 600, the upper control would get 200 and the bottom 300.
I have no idea at design time how much space each will want in proportion to the other, so using 1*, 2* etc. for row height won't work for me.
I can hand-code run-time proportional sizing, but am I missing a simple trick in XAML that would get me what I want?
Context is as follows (trimmed for brevity)...
<Grid>
<TabControl>
<TabItem>
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" Header="Title Area" />
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<UserControl />
</ScrollViewer>
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto">
<UserControl />
</ScrollViewer>
</Grid>
</Grid>
</TabItem>
</TabControl>
</Grid>