Working with Graphic Layouts and Groups in Silverlight 2
Layout panels, such as Grids and Canvases, are the foundation of Silverlight and WPF applications. They act as containers for visual elements. By default, layout panels are adaptive in nature. For example, when you build an interface, the panel automatically adjusts to the size of the window.
Layout panels also allow you to apply transforms. This capability is useful when animating a group of visual elements, because the animation is applied to the layout panel and not to each individual element.
In this chapter, you'll learn about the types of layout panels in Silverlight 2 and how to use them.
Selecting the Correct Layout Panel
In Blend, the main layout panels are the Grid, Canvas, Stack, Wrap, and Dock panels. (Note that the Wrap and Dock panels are specific to WPF.) You select a panel based on how you want the elements in the panel to appear.
Table 4.1. Layout Panel Types
LAYOUT PANEL |
BEHAVIOR |
Grid |
Visual elements are arranged in rows and columns. See "Working with the Grid Panel." |
Canvas |
Visual elements are arranged in fixed positions. See "Working with the Canvas Panel." |
Stack |
Visual elements are arranged in a horizontal or vertical line. See "Working with the Stack Panel." |
Wrap (WPF only) |
Like the Stack panel, the Wrap panel arranges items in a single line. Unlike the Stack panel, the Wrap panel wraps items to a new line when they run out of room. |
Dock (WPF only) |
Visual elements lock to the edge of the panel. |