1
votes

Writing a small WPF app here but I can't crack this problem:

I have a panel at the bottom of a window that the user should expand/collapse at the click of a button. Also, when expanded, the user should be able to resize it by dragging a GridSplitter.

To build this I have laid out the controls in a three-row Grid:

Row[0](Height=*)    = some content (not important for the problem)
Row[1](Height=5)    = GridSplitter (I have also tried setting Row Height to Auto)
Row[2](Height=Auto) = the resizable/expandable/collapsable "panel"

I have tried controlling the height of the "panel". That allows for expanding/contracting but when resizing with the GridSplitter the "panel" doesn't stretch to be resized. I have tried resetting the "panel" Height = double.NaN and it's VerticalAlignment = VerticalAlignment.Stretch when the user starts dragging the splitter but that doesn't work.

If I do not try to control the "panel" Height explicitly it stretches as expected and can be resized by the GridSplitter but that won't allow for Expanding/Contracting at the click of a button.

Any tips on how to achieve both of these features would be great!

1
I think you may want a trigger which sets the Height of the grid row to Auto when the panel is collapsed. Example XAML reproducing the behavior would help.15ee8f99-57ff-4f92-890c-b56153
Please post the code for the complete grid.BionicCode
@EdPlunkett Yup, that was the trick! I had to write a custom animation class (one that doesn't rely on DependencyProperty) for it all to work but controlling the row height (only) did the trick. If you like some cred please just re-write your comment as a reply and I'll set it as the answer. Cheers!Jonas Rembratt

1 Answers

1
votes

If it's a trigger -- the simplest way -- you can give a RowDefinition a Style, and put the trigger in the Style.Triggers section of the Style.