
Arranging Content with Panels
When you are building a GUI using Silverlight, you are required to make use of panel types. Recall that a
ContentControl can only have one item assigned to its Content property.
If you were to add a UI widget directly to a ContentControl, it will be positioned in the dead center. Consider
the following simple UserControl, which sets a Rectangle as content (note the lack of any panel type):
<UserControl x:Class = "SimpleSilverlightApplication.Page"
xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml"
Height = "300" Width = "300">
<Rectangle Fill = "Black" Height = "50" Width = "100"/>
</UserControl>
Multiple UI elements must first be arranged in one of the provided panel types. Here are the most frequently
used panel types, all of which are defined in the System.Windows.Controls namespace of
PresentationFoundation.dll. Silverlight also supplies a TabControl, which will be examined a bit later in this
chapter.
Be aware that each one of these panel types can be configured in numerous ways. You will most certainly
want to look up panels of interest in the Silverlight SDK documentation for full details.
Panels
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Training Resources
Tutorials
WPF Panel Type
|
Meaning in Life
|
Canvas
|
Provides a ‘classic’ mode of content placement. Items stay exactly where you put them at design time as items make use of absolute positions.
|
Grid
|
Arranges content within a series of cells, based on rows and columns, maintained within a tabular grid.
|
StackPanel
|
Stacks content in a vertical or horizontal manner as dictated by the Orientation property.
|
|
Services
Courseware