# How to: Draw a Rectangle

This example shows how to draw a rectangle by using the Rectangle element.

To draw a rectangle, create a Rectangle element and specify its Width and Height. To paint the inside of the rectangle, set its Fill. To give the rectangle an outline, use its Stroke and StrokeThickness properties.

To give the rectangle rounded corners, specify the optional RadiusX and RadiusY properties. The RadiusX and RadiusY properties set the x-axis and y-axis radii of the ellipse that is used to round the corners of the rectangle.

In the following example, two Rectangle elements are drawn in a Canvas. The first rectangle has a Blue interior. The second rectangle has a Blue interior, a Black outline, and rounded corners.

## Example

``````  <Canvas Width="120" Height="200" >

<!-- Draws a 100 by 50 rectangle with a solid blue fill. -->
<Rectangle
Width="100"
Height="50"
Fill="Blue"
Canvas.Left="10"
Canvas.Top="25" />

<!-- Draws a 100 by 50 rectangle with a solid blue fill,
a black outline, and rounded corners. -->
<Rectangle
Width="100"
Height="50"
Fill="Blue"
Stroke="Black" StrokeThickness="4"