Controls
Silverlight 2 has over 3 dozen User Interface (UI) controls. .NET programmers already familiar
with ASP.Net or (especially) WPF, will find using the Silverlight controls very natural and
straight forward.
Figure 1-1. Silverlight Controls (split in two to make it easier to view)
Silverlight controls were created to look great and provide extensive and customizable
functionality right out of the box. Moreover, all of the standard controls can be modified in
numerous ways to meet your needs.
The look and feel of the control can be tweaked through styles or can be entirely redesigned
through templates, and the behavior of the controls can be modified through event handlers. In
the rare cases when none of that is enough, you can create (or derive) your own customized
controls as well.
This tutorial will cover event handlers. Styles, Templates and Custom Controls will be covered
in future tutorials. .
A Note On The Design Surface
The current Visual Studio design surface is read-only. That is, you can drag and drop controls
into the markup (or write the Xaml by hand) and the effects are seen immediately in the design
surface, but you cannot yet drag or otherwise manipulate controls directly in design mode.
That is a temporary limitation. For now, one alternative is to use Expression Blend, and we have
a full tutorial on Blend for Programmers that shows how to work with the two environments
together.
Note that controls can also be created dynamically (in code, at run time) as explained at the end
of this tutorial.
Layout Controls
The use of layout controls is both straight-forward and essential to the creation of Silverlight
applications. Layout controls are used to manage the placement of other controls (including other
layout controls!) in your Silverlight application. You can think of the layout controls as
"containers."
The three Layout controls you'll use most often are:
• Grid - essentially a table used for positioning objects in rows and columns.
• StackPanel