I would like to make a sector of a circle on WP7. I tried to do this with the ellipse class and I found a lot of solution, which make a gauge or pie chart or something, but I need just the essence. Could anyone help?
the aim is to show just one part of a circle (or ellipse). Like the yellow area in the picture:
Thanks, Laci
Here's a fairly simple solution to the problem, though it does not use an
Ellipse
and it requires a little trigonometry:The
Data
property uses Path Markup Syntax.RotationAngle
,IsLargeArc
, andSweepDirection
(1 for clockwise, 0 for counter-clockwise)).Where did the 70.7 come from? Well, this particular arc sweeps out an angle of 45 degrees from a circle with radius 100, so the coordinates 70.7,-70.7 are determined by
100 * sin(45)
and100 * cos(45)
.you need to do something like this:
define the visible part of the canvas (clip). For this part you need to use PathGeometry as the Clip to define the slice of the circle you want to be visible. (see link)
Alternatively you can use CombinedGeometry to combine a PathGeometry and EllipseGeometry to form the slice. (the link provides a good example of CombinedGeometry)