I need to draw a semicircle / half circle in WPF. Any idea how to do that? Thanks for any hint!
Asked
Active
Viewed 1.2k times
2 Answers
8
ArcSegment
would be a good place to start.
And here is a good example of how to use it in code.
-
2Might have been this one http://blogs.vertigo.com/personal/ralph/Blog/Lists/Posts/Post.aspx?ID=5 – PaulB Apr 28 '11 at 13:21
-
2Second link is dead... some information in the answer itself would be highly appreciated. – grek40 Jul 14 '17 at 12:13
8
Since the original link is dead, here's how I was able to draw an arc:
<Canvas>
<Path Stroke="Gray">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="0,20">
<PathFigure.Segments>
<PathSegmentCollection>
<ArcSegment Size="20, 20"
IsLargeArc="True"
SweepDirection="CounterClockwise"
Point="40,20" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
That produces the following image (with added markings for some of the variables)
The XAML above is a modified version of the XAML found here:
https://www.c-sharpcorner.com/UploadFile/mahesh/drawing-arc-using-arcsegment-in-xaml/

Victor Chelaru
- 4,491
- 3
- 35
- 49
-
I am a bit confused by these figures. If the Width is 20 and the height is 20, how is it possible that the Point for the ArcSegment has a 40 in its coordinates? – nacho10f Aug 04 '22 at 16:59
-
Thank you, I don't know how I missed that. I've updated the image to be correct. – Victor Chelaru Aug 05 '22 at 14:49