views:

228

answers:

1

The following code puts the two text elements at the top even though the second one is marked "Bottom". The background color goes all the way to the bottom so the DockPanel seems to stretch to the bottom.

What am I not understanding about DockPanel?

<Window x:Class="TestIndexer934.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:TestIndexer934.Commands"
    Title="Main Window" Height="400" Width="800">
    <DockPanel HorizontalAlignment="Left" Background="Beige">
        <TextBlock DockPanel.Dock="Top" Text="Testing top"/>
        <TextBlock DockPanel.Dock="Bottom" Text="Testing bottom"/>
    </DockPanel>
</Window>
+6  A: 

By default a DockPanel's last item will fill the remaining content area available.

If you set LastChildFill="False" on the DockPanel, you'll see the behavior you are expecting. You can also set VerticalAlignment="Bottom" on the TextBlock.

rmoore
Quite likely the case here. see: http://msdn.microsoft.com/en-us/library/system.windows.controls.dockpanel.lastchildfill.aspx
Jonathan Fingland
thanks, that works, I remember seeing that attribute, now know what it's for
Edward Tanguay