Chapter 7. Panels
This chapter covers
- Absolute layout with the Canvas
- Stacking items with the StackPanel
- Cell-based layout with the Grid
Panels in Silverlight provide a way to host multiple elements and provide unique layout logic. For example, you may want a panel that lays out elements so they appear to radiate out of a central point (think of the wheel on Wheel of Fortune). Rather than provide each and every control with the knowledge required to perform that layout, Silverlight leaves it to the panel.
This delegation to panels and the layout system is why you won’t see Left and Top properties on UI elements—those properties are provided by the panels in the form of attached properties (see section 2.1.5 for more information on attached properties).
In typical use, any control you place in the UI in Silverlight is going to be hosted in a panel at some level. Understanding how the different panels work is essential to making the most of Silverlight’s UI capabilities.
Though there are numerous types of panels available, the three most important and widely used are the Canvas, the StackPanel, and the Grid.