Drawing Shapes: The Rectangle

The Rectangle element is another common geometric shape that you can utilize in custom control templates. Drawing a rectangle is easy, as demonstrated in the following code example:

<Rectangle Width="150" Height="50"           Fill="Orange" Stroke="Red"           StrokeThickness="3"/>

You define its dimensions, specifying Stroke and StrokeThickness as for the ellipse (optional). Figure 29.16 shows how the object is drawn.

Image

FIGURE 29.16 Drawing a rectangle.

Rectangle also has the RadiusX and RadiusY properties that you can assign to round corners.

Get Visual Basic 2015 Unleashed 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.