How to set the initial height of the "GridSplitter" panel?

I am using GridSplitter in my WPF window. Above the separator is a TreeView, below is a DockPanel, among other things, a text field. When I select an item in a TreeView, the contents of the DockPanel are updated by data binding.

Depending on the contents of the TextBox, the bottom pane of the window expands and contracts in size. I want it to start with Height X and stay at that height if the GridSplitter user is not being dragged.

I tried to set the height of the bottom DockPanel in XAML, but this fixes the height of the DockPanel so that it does not change when moving the GridSplitter. Maybe the solution is related to Grid.Row Heights?

Here is the general structure of my page.

Window Grid row1 Height="*": TreeView row2 Height="5": GridSplitter row3 Height="auto": DockPanel // gets taller and shorter depending on its content. ... TextBox 

BTW: after I dragged the GridSplitter, the resizing stops happening and the user interface behaves the way I want.

+7
source share
1 answer

Explicitly set the Height grid line for which you want to have an initial size.

Currently row3 is set to Auto and changes to content as soon as you drag the GridSplitter whose value is replaced by the current row height.

+8
source

All Articles