Since the first beta release of Silverlight 2 there was a lot of talk about controls like a TreeView, auto complete TextBox, WrapPanel, DockPanel etc, and because of the high demand some custom controls were created. Last week the Silverlight Toolkit was released and introduced the so long awaited controls. In this article we'll take a closer look to one of them - the DockPanel.
Introduction
The DockPanel is a layout control, like the StackPanel and the Grid, but in some cases is far more powerful than them. The idea of the control is that you can "dock" its child controls in all of the four directions - top, bottom, left, right (compared to the StackPanel, which allows only two directions - top->bottom and left->right). That gives us pretty much freedom when designing our application's UI. Freedom in sense that the count of the nested controls will be less, which means less code and more simple structure of the XAML, or you don't have to bother to define the structure of a Grid first.
Here are some basic guidelines about the behavior of the control ( we'll take a closer look at some of them later on in the article):
- You can align the child controls to the top, bottom, left or right. The default alignment is to left.
- The child controls take the place that is left after placing the previous child controls.
- You can fill the rest of the place with the last child control. The DockPanel does this by default.