As you have already seen in this chapter, basic shapes, such as rectangles, ellipses, or lines, can be defined declaratively in the XAML language. However, they can also be created programmatically using the C# language, as you will see in this recipe.
As an example, you will create a simple page with the
Canvas control, where a rectangle, an ellipse, a polygon, a polyline, and a set of lines will be drawn.
To step through this recipe, you need only the automatically generated project.
To prepare the example that draws a rectangle, an ellipse, a polygon, a polyline, and a set of lines programmatically, perform the following steps: