This article is compatible with the latest version of Silverlight.
Introduction
Layout controls are Silverlight controls which act as containers of other controls. Their main purpose is the positioning and arranging of their child controls. There are several layout controls: Canvas, StackPanel and Grid and TabPanel.
See also:
Canvas Article
StackPanel Article
Grid Article
Overview
All layout controls derive from the basic abstract class Panel.
There are also four more descendants of the Panel Class: DataGridCellsPresenter, DataGridColumnHeadersPresenter, DataGridDetailsPresenter, DataGridRowsPresenter. Their purpose is the positioning of elements in a DataGrid template. They are not standalone controls.
Layout controls inherit the Children collection of type UIElementCollection. Since all elements in this collection are UIElement objects and the Panel itself derives from UIElement layout controls can be nested in one another without limitation.
The following example demonstrates the nesting:
Note: to understand this example you should be familiar with all layout controls: Canvas, StackPanel and Grid
We want to have the following meaningless result (I don’t like giving real world examples, I just want to show you how nesting of layout controls works.):