Grid Row auto size priority

Hello,

I have a grid,

<Grid.RowDefinitions>

<RowDefinition Height="Auto" />

<RowDefinition Height="Auto" />

<RowDefinition Height="Auto" /> - contains ScrollViewer

<RowDefinition /> - contains ListBox

</Grid.RowDefinitions>

and as I size the window to smaller and smaller heights, I see:

The first three rows have the same height all the time regardless the fact they do not fit into the window anymore.

The last row fills the remaining space, it gets smaller and smaller until it does not fit into the window, and then disappears.

What I need is to keep the last row height at some minimum. If it reaches that minimum, I'd like the third row to begin shrinking. If even that one does not fit any more into the window, let the remaining rows to be cropped as usual. My idea results in only the last row being visible in extremely small sizes.

However, it is not that easy. If I set MinHeight="100" to the last row definition (or to the ListBox), it indeed has fixed height of 100 when there is a little space remaining, but since the preivous rows heights are also fixed - Auto, further shrinking of the window causes the ListBox to be cropped.

This should express the behaviour I want:

<Grid.RowDefinitions>

<RowDefinition MinHeight="0" StandardHeight="Auto"MaxHeight="Auto" />

<RowDefinition MinHeight="0" StandardHeight="Auto"MaxHeight="Auto" />

<RowDefinition MinHeight="0" StandardHeight="Auto"MaxHeight="* - 100" /> - contains ScrollViewer

<RowDefinition MinHeight="100" StandardHeight="*"MaxHeight="Infinite" /> - contains ListBox

</Grid.RowDefinitions>

How to achieve this?

[4149 byte] By [JanKu?era] at [2008-1-8]
# 1

Hi Jan,

As long as your row Height is Auto, they will not shrink. They are fixed to the size of any children content. Are you sure those rows need to be sized to Auto?

The layout you want is possible, but perhaps not possible without a little custom code. Can you try describing it with a little more detail?

Cheers,

Bryan

BryanWheeler--MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

If they were fixed size, there wouldn't shrink either.

The content in the first two row does not resize. So I could just hide them from the code if necessary. However, the main problem is in the third row. I have a control in there, which resizes itself. I want it to be able to resize, but not so much that it would grow over and hide the last row, which I need to keep visible in any case.

If this is not clear enough, I should rather create a drawing or animation ;-) ..let me know.

Jan

JanKu?era at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

Is your 4th row fixed in size? In that case, why not have

<Grid.RowDefinitions>

<RowDefinition Height="Auto" />

<RowDefinition Height="Auto" />

<RowDefinition Height="*" /> - contains ScrollViewer

<RowDefinition Height="100"/> - contains ListBox

</Grid.RowDefinitions>

That way, your 3rd row gets all the remaining space.

If I'm still not understanding what you are trying to do, perhaps the drawing or animation might do the trick :-).
BryanWheeler--MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified