14.11. Layout Controls

The main layout controls in Silverlight are the following:

  • Canvas

  • StackPanel

  • Grid

14.11.1. Canvas

Canvas is the simplest of all the layout controls. You can think of it as a rectangle or <div> tag in which you put content. Content added to a canvas is normally then positioned absolutely by setting the Canvas.Left and Canvas.Top properties. Canvas is unique from the other layout controls in that it is the only layout control that allows you to modify the Z index (or which elements on top of which).

14.11.2. StackPanel

A StackPanel allows you to set items positioned within them to flow horizontally or vertically by setting a property called Orientation to either Vertical or Horizontal (see Figure 14-7).

Figure 14.7. Diagram ...

Get Introducing .NET 4.0: with Visual Studio 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.