In my WPF Window, I've got a Status Bar and a TextBox. Now what I want to achieve is in my code, I have a button which collapses and shows the Status Bar. When I click on the button, the Status Bar collapses therefore the control will be collapsed and no longer shown and so the Textbox will fill the space of the Status Bar. When the button is pressed again, the Status bar will be visible and will push the Textbox up.
I've tried only this but it didn't work. THe problem is that the Status Bar would hide but the textbox would still be in the same place and not take up the space. Someone please help me that would be greatly appreciated.
<StackPanel>
<Grid>
<StatusBar Height="30" VerticalAlignment="Bottom">
<StatusBarItem Content="Last Saved Not Saved"/>
<StatusBarItem HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal">
<StatusBarItem Content="Character 0 Word 0"/>
<StatusBarItem Content="Ln 1, Ch 0"/>
</StackPanel>
</StatusBarItem>
</StatusBar>
<TextBox x:Name="textBox" Height="380" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Margin="0,24,0,0"/>
</Grid>
</StackPanel>
DockPanelinstead? That is withoutGridinside it. You would have to useDockPanel.Dockto set the Controls in the right places. Another thing useHeightproperty on theDockPanelrather than theTextBox, this wayTextBoxwill stretch. HTH<DockPanel MinHeight="380" LastChildFill="True"><StatusBar DockPanel.Dock="Top" Height="30"/><TextBox DockPanel.Dock="Bottom"/>. This is of top of my head so you might want to tweak it a bit, but you should get the idea.