Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-draw-an-ellipse-or-a-circle.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

2.4 KiB

title, description, ms.date, helpviewer_keywords, ms.assetid
title description ms.date helpviewer_keywords ms.assetid
How to: Draw an Ellipse or a Circle Learn how to draw an ellipse or circle with choices for outline thickness and interior color in Windows Presentation Foundation (WPF). 03/30/2017
ellipses [WPF], drawing
circles [WPF], drawing
drawing circles [WPF]
drawing ellipses [WPF]
graphics [WPF], drawing circles
graphics [WPF], drawing ellipses
99763b8c-bfc8-44be-8231-8a70daf5481a

How to: Draw an Ellipse or a Circle

This example shows how to draw ellipses and circles by using the xref:System.Windows.Shapes.Ellipse element. To draw an ellipse, create an xref:System.Windows.Shapes.Ellipse element and specify its xref:System.Windows.FrameworkElement.Width%2A and xref:System.Windows.FrameworkElement.Height%2A. Use its xref:System.Windows.Shapes.Shape.Fill%2A property to specify the xref:System.Windows.Media.Brush that is used to paint the interior of the ellipse. Use its xref:System.Windows.Shapes.Shape.Stroke%2A property to specify the xref:System.Windows.Media.Brush that is used to paint the outline of the ellipse. The xref:System.Windows.Shapes.Shape.StrokeThickness%2A property specifies the thickness of the ellipse outline.

To draw a circle, make the xref:System.Windows.FrameworkElement.Width%2A and xref:System.Windows.FrameworkElement.Height%2A of the xref:System.Windows.Shapes.Ellipse element equal to each other.

The following example draws four xref:System.Windows.Shapes.Ellipse elements within a xref:System.Windows.Controls.Canvas.

Example

[!code-xamldrawingwithshapeelements#EllipseExample1]

Although this example uses a xref:System.Windows.Controls.Canvas to contain the ellipses, you can use ellipse elements (and all the other shape elements) with any xref:System.Windows.Controls.Panel or xref:System.Windows.Controls.Control that supports non-text content.

This example is part of a larger sample; for the complete sample, see Shape Elements Sample.

See also