tags:

views:

306

answers:

4

I have two Expanders in a grid, both in Auto sized rows. When the height of the Expander is very large, the row overflows out of the grid.

Is there a way to have Auto sized rows that take only the grid space that's available?

A: 

Try setting the MaxHeight property on either the expander object or the object inside the expander.

klennepette
But then it doesn't take all the available space...
Janet
A: 

You could use a DockPanel instead - and then dock the first Bottom and let the other fill. Or put each Expander inside a ScrollViewer.

Goblin
That kinda works, but if both expanders are large one will take all the space instead of evenly dividing it.
Janet
A: 

i would set the last rowDefinition to Height="*", then the last row fills out all the space left.

but it doesnt help if not only the last row would overflow..

SwissCoder
A: 

See my custom auto-sizing panel/grid class here. I wrote it specifically to address this problem--full source is in the question.

(To use it, create a new class that inherits from panel and paste the working code into the class, then use the custom class just like a StackPanel.)

It currently only supports Vertical orientation, but could easily be modified to support Horizontal as well.

chaiguy