WORKING WITH SHAPES

The majority of the time, the standard set of Silverlight controls is all you need to create rich Windows Phone 7 applications. However, depending on the app, you may need additional capabilities, such as drawing. For example, if you write a basic paint program or perhaps a photo editing solution on the phone, you need the ability to draw basic shapes on the screen. In addition to the standard controls, Silverlight provides a set of basic shapes. Using these shapes is simple and straightforward. In no time, you can get a basic paint program up-and-running. With the multitouch capabilities of the Windows Phone 7 hardware, you can create some intriguing solutions.

The Ellipse Control

The Ellipse control provides a simple way to create circle-type objects on the screen. A handful of properties make up the definition of the ellipse. At a minimum, you should count on setting the Height and Width properties, which determine the overall size and shape of the ellipse. In addition, you should set the Stroke property, which determines the outline color of the ellipse. You also have several options related to Stroke, such as StrokeThickness, that allow for further customization.

You add an Ellipse control with code like the following:

<Ellipse x:Name=“MainEllipse” Width=“200” Stroke=“White” StrokeThickness=“5”
Height=“100” Fill=“Blue” / >

In this case, you'd create a blue ellipse with a relatively thick white outline, as shown in Figure 3-1.

This shape closely resembles ...

Get Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® 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.