views:

251

answers:

1

Below I say "DockPanel.Top" on Menu but it docks in the middle. (?)

If I take the Height attribute out of Menu it docks on top but is about 200px high. (?)

I thought that was what LastChildFill was for.

How can I get this child element of DockPanel to dock on the top with no other items in the dockpanel?

<Window x:Class="TestContainer1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="480" Width="600" Loaded="Window_Loaded">

    <DockPanel HorizontalAlignment="Stretch" 
               Margin="0,0,0,0" 
               Width="Auto" 
               LastChildFill="True">

        <Menu x:Name="panelMenuTop" 
              Width="Auto" 
              Height="25" 
              DockPanel.Dock="Top">

            <MenuItem Header="File">
                <MenuItem Header="Close" 
                          Click="CloseApplication_Click"/>
            </MenuItem>
        </Menu>

    </DockPanel>
</Window>
A: 

Your menu is filling up the entire area so it appears centered. You can just give the Menu a VerticalAlignment="Top" or give the DockPanel some more children as Henk said.

Bryan Anderson