DockPanel Class
[Note: This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Arranges child elements around the edges of the panel. Optionally, the last added child element can occupy the remaining space.
Assembly: System.Windows.Controls (in System.Windows.Controls.dll)
DockPanel is one of the Panel controls that enables layout. DockPanel is used when you want to arrange a set of objects around the edges of a panel. You specify where a child element is located in the DockPanel with the Dock property. If you set the LastChildFill property to true (the default value) and the last element is allowed to resize, the last element added to the panel will resize to fill the remaining space. If the last element is set to a specific size, the last element will be set to the specified size and positioned in the middle of the remaining space.
The order in which elements are added to the DockPanel is important. For example, if you add three child elements that have their Dock properties set to Left, they will stack from the left side of the control with the last element added the furthest right. If elements are added that exceed the space of the DockPanel, the last elements that are added that exceed the space of the panel will be truncated.
The following image shows a DockPanel control with the last child filling the middle of the control.
The following table summarizes the other available layout containers provided by Silverlight.
|
Panel Name |
Description |
|---|---|
|
Defines an area that you can explicitly position child elements. |
|
|
Defines a flexible grid area consisting of columns and rows. |
|
|
Arranges child elements into a single line that can be oriented horizontally or vertically. |
|
|
Positions child elements sequentially from left to right or top to bottom. When elements extend beyond the panel edge, elements are positioned in the next row or column. |
The following example shows a DockPanel with child elements positioned at the edges of the panel and the last child filling the remaining space.
<Border BorderBrush="Black" BorderThickness="3" > <StackPanel x:Name="LayoutRoot" Background="White"> <TextBlock Margin="5" Text="Dock Panel" /> <Border BorderBrush="Black" BorderThickness="3" > <controls:DockPanel LastChildFill="true" Height="265"> <Button Content="Dock: Left" controls:DockPanel.Dock ="Left" /> <Button Content="Dock: Right" controls:DockPanel.Dock ="Right" /> <Button Content="Dock: Top" controls:DockPanel.Dock ="Top" /> <Button Content="Dock: Bottom" controls:DockPanel.Dock ="Bottom" /> <Button Content="Last Child" /> </controls:DockPanel> </Border> </StackPanel> </Border>
System.Windows.DependencyObject
System.Windows.UIElement
System.Windows.FrameworkElement
System.Windows.Controls.Panel
System.Windows.Controls.DockPanel
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.