xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Ellipse
Height='200' Width='200'
Stroke='Black'
StrokeThickness='10'
Fill='Yellow'/>
<Rectangle
Canvas.Left='80'
Canvas.Top='80'
Height='200' Width='200'
Stroke='Black'
StrokeThickness='10'
Fill='LightBlue'/>
</Canvas>
Reload the Default.html
file in the web browser, and notice that the ellipse is now on top of the rectangle (see Figure 19-5).

Figure 19-5
You can also nest Canvas controls within one another. Edit the UI.xaml
file created earlier and replace its content with the following:
<Canvas
xmlns='http://schemas.microsoft.com/client/2007'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
</Canvas>
Reload the Default.html
file in the web browser, and observe the changes (see Figure 19- 6).

Figure 19-6
The positions specified by the Canvas.Left
and Canvas.Topattributes
of each element or control are relative to its parent control, and not the root control.
One of the key capabilities of Silverlight is the support for drawing objects of different shapes and sizes. Silverlight provides the following basic shape elements:
□ Rectangle
□ Ellipse
□ Line
□ Polygon
□ Polyline
A <Rectangle>
element draws a rectangle (or square) with optional rounded corners. To specify rounded corners, use the RadiusX
and RadiusY
attributes. Edit the UI.xaml
file created in the previous section and replace its content with the following:
<Canvas
xmlns='http://schemas.microsoft.com/client/2007'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
</Canvas>
Reload Default.html
in the web browser. Figure 19-7 shows the output.

Figure 19-7
A <Line>
element draws a line on the Canvas control. Edit the UI.xaml
file created in the previous section and replace its content with the following:
<Canvas
xmlns='http://schemas.microsoft.com/client/2007'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
</Canvas>
Reload the Default.html
file in the web browser, and observe the output (see Figure 19- 8).

Figure 19-8
An <Ellipse>
element draws a circle (or oval) on the Canvas
control. Edit the UI.xaml
file created in the previous section, and replace its content with the