How to drive pie shapes? RRS feed

  • Question

  • Hi!

    I'm playing with the idea of making an application for pupils to learn to add and subtract fractions. But I already got stuck at the beginning because I can't figure out how to divide a circle (ellipse object) into four pie slices and how to fill one or more of them. Can someone give me a nudge in the right direction?

    Thanks, Sigurd F

    Thursday, May 15, 2014 7:26 PM


All replies

  • You can use a Path object with an ArcSegment to describe your slice. See Move and draw commands syntax for a discussion of how to describe the path.
    Thursday, May 15, 2014 8:17 PM
  • The WinRTXamlToolkit on CodePlex contains ready-to-use PieSlice and RingSlice classes for that (they're drawing the ArcSegments for you). It's also available through NuGet.

    If you want a sample on creating rings or pies with differently colored segments, then check this post.

    Friday, May 16, 2014 6:32 AM
  • Thanks, but I think it would be better to write the code from scratch.

    Sigurd F

    Tuesday, May 20, 2014 1:33 PM
  • Will it more or less be the same doing this by code? I have been searching the internet for serveral days now, but can't find a way to solve this.

    Regards, Sigurd F

    Wednesday, May 21, 2014 10:01 AM
  • Yes, you can create the Path object, LineSegments, ArcSegments, etc. by code. You'll follow essentially the same object structure as in the Xaml in Quickstart: Drawing shapes and in Scenario 5 of the XAML vector-based drawing sample  but you'll new the objects from code.

    You'll have to do a bit of trigonometry to find the points of the segments from the radius and sweep angle but it shouldn't be difficult.


    Thursday, May 22, 2014 12:20 AM