Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill an pie shape area in WPF XAML

Tags:

c#

wpf

xaml

I have the following XAML:

    <Ellipse StrokeThickness="2" Stroke="Green"></Ellipse>
    <Rectangle Margin="150,0,149,150" Name="rectanglePie" Stroke="Green" Height="150" VerticalAlignment="Bottom">
        <Rectangle.RenderTransform>
            <RotateTransform x:Name="pieEdge" CenterX="0" CenterY="150" Angle="60" />
        </Rectangle.RenderTransform>
    </Rectangle>

    <Rectangle Margin="150,0,149,150" Name="rectangleStatic" Stroke="Green" Height="150" VerticalAlignment="Bottom">
    </Rectangle>

What I would like to do is to fill the pie slice that this contains with a colour. Is this possible, and if so, how would I go about this?

like image 658
Paul Michaels Avatar asked Sep 29 '22 16:09

Paul Michaels


1 Answers

To get you started...

<Canvas>
    <Path Canvas.Left="150"
          Canvas.Top="150"
          Fill="Blue"
          Stroke="Black">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="0 0"
                            IsClosed="True">
                    <LineSegment Point="200 110" />
                    <LineSegment Point="-100,100"/>
                    <ArcSegment x:Name="arc"
                                Size="100 100"
                                SweepDirection="ClockWise" />
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
</Canvas>
like image 147
Core-One Avatar answered Oct 03 '22 11:10

Core-One