-->

Sunday, August 11, 2013

DockPanel Overview in WPF

DockPanel Overview in WPF

It is somewhat different with wrap panel. The name Dock panel is created by the word Dock. Dock element provides the user with a way of launching, switching between running applications. Dock panel provides easy docking of elements to an entire side of the panel, stretching it to fill the entire side. It also enables a single element to fill all the remaining space unused by the docked elements.

DockPanel with four children

There are four possible dock in a dock panel i.e. left, top, right and bottom. A children can itself control its dock with these four values. The dock property of any child is left by default. In the above image only four buttons are used, if we add a fifth button in this then the fourth one will shift to bottom and the fifth one will be placed in center like in following image.

DockPanel with five children

Dock panel supports number of children as per requirements. Elements are stacked in the appropriate direction when multiple elements are docked in the same direction. If we will place a sixth element then it will stacked with the First element. The xaml code for the above dock panel image is:
<DockPanel>
<Button Content="First" DockPanel.Dock="Left"></Button>
<Button Content="Second" DockPanel.Dock="Top"></Button>
<Button Content="Third" DockPanel.Dock="Right"></Button>
<Button Content="Four" DockPanel.Dock="Bottom"></Button>
</DockPanel>
Grid panel

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved