WPF: Creating ellipse or rectangle using canvas

This entry is part 52 of 54 in the series Learn WPF

Using WPF, we can create ellipse or rectangle using XAML canvas.

The following example create a red ellipse and a blue rectangle.

<Window x:Class="Ellipse.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <Ellipse Fill="Red" Width="100" Height="60" />
        <Rectangle Fill="Blue" Width="80" Height="80" Canvas.Left="100" Canvas.Top="100" />
        <Button Content="Hello" Canvas.Left="130" Canvas.Top="30" FontSize="20" />

The output from running the above code is:



Series Navigation<< WPF: Accessing attached properties
WPF: Creating overlapping rectangles using canvas >>