Tuesday, October 13, 2015

WPF: DockPanel - When to use?



Dockpanels 


are useful when when placing and organising several different items onto a window, specifically when anchoring items to the top, bottom, left, right and then fitting to the remaining space in the centre (I recently discovered they're quite handy when used in conjunction with expanders). No real downsides, could well be effective for you.

XAML: 

<Window x:Class="WpfTutorialSamples.Panels.DockPanel"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="DockPanel" Height="250" Width="250">
        <DockPanel>
                <Button DockPanel.Dock="Left">Left</Button>
                <Button DockPanel.Dock="Top">Top</Button>
                <Button DockPanel.Dock="Right">Right</Button>
                <Button DockPanel.Dock="Bottom">Bottom</Button>
                <Button>Center</Button>
        </DockPanel>
</Window>

No comments:

Post a Comment