Posted by : Sudhir Chekuri Thursday, 3 October 2013

Dock panel is used to hold child controls inside it which can be docked to the edges of dockpanel.
If the control inside dock panel is not docked then it will be occupying the enter middle space.
DockPanel.Dock property is used to give location where it has to be  docked.
In the below example there is a dockpanel with 5 labels. 4 labels are docked to 4 edges and one without dock.

XAML Code for dockpanel with labels docked to all sides

<Window x:Class="WpfAppLayouts.Window3"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window3" Height="300" Width="300">
    <Grid>
        <DockPanel>
            <Label DockPanel.Dock="Top" Height="100" Background="Red">Top</Label>
            <Label DockPanel.Dock="Left" Background="Pink"  >Left</Label>
            <Label DockPanel.Dock="Right" Background="Yellow" >Right</Label>
            <Label DockPanel.Dock="Bottom" Background="Green" >Bottom</Label>
            <Label Background="BlueViolet" >Fill</Label>
        </DockPanel>
    </Grid>
</Window>

Output


Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

Blog Archive

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -