Reputation: 4798
I know the order of DockPanel
children elements matters. I've read somewhere that layout of a child is determined based on the available space left after all previous children have already been positioned. So for example for this piece of code:
<DockPanel>
<Button DockPanel.Dock="Bottom" Height="20" Content="MyButton"/>
<DataGrid Name="dataGrid" ItemsSource="{Binding CarList.Items}"/>
</DockPanel>
I'm getting a result like picture below where my Button is docked to the bottom as expected:
Now if I change the order of children elements like this:
<DockPanel>
<DataGrid Name="dataGrid" ItemsSource="{Binding CarList.Items}"/>
<Button DockPanel.Dock="Bottom" Height="20" Content="MyButton"/>
</DockPanel>
The layout gets weired:
Regardless of the fact that my Button uses the available space left, shouldn't at least it gets docked to the bottom of this space?
Upvotes: 3
Views: 1544
Reputation: 5666
You are not considering the DockPanel
LastChildFill property. As you can read:
true if the last child element stretches to fill the remaining space; otherwise false. The default value is true.
Anyway you can find a good tutorial here.
Upvotes: 4