[ACCEPTED]-How to make items in a DockPanel expand to fit all available space in WPF?-dockpanel
Use a DockPanel instead. StackPanel explicitly 12 doesn't care about visible space, whereas 11 DockPanel does all of it's size calculation 10 based on available space.
Update:
In addition, in 9 my experience, putting the body of the window 8 into a View, and only having the View in 7 the Window makes for a better Auto Size 6 experience.
For some reason putting all 5 of the children directly into the Window 4 seems to not auto size very well.
Update 2:
I would 3 remove the explicit DockPanel.Dock attribute 2 from the element that you want to stretch 1 (fill) the unused space.
This should do it - I set it up so that 4 the TreeView and the ListView shared the 3 main view 50/50; if you don't want that, set 2 it to 'Auto' and '*' or something. Use "LastChildFill" to 1 your advantage!
<Window x:Class="Clippy.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="400" Width="600" MinHeight="400" MinWidth="600" Loaded="Window_Loaded" SizeChanged="Window_SizeChanged">
<DockPanel LastChildFill="True">
<Menu Width="Auto" DockPanel.Dock="Top" />
<ToolBar Width="Auto" DockPanel.Dock="Top" />
<StatusBar DockPanel.Dock="Bottom" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
<TreeView Name="categoryTreeView" Grid.Row="0" />
<ListView Name="clipListView" Grid.Row="1" />
</Grid>
</DockPanel>
</Window>
Set width and height properties to "auto"
0
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.