如何在WPF XAML中填充饼形区域

5

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>

我想要做的是用颜色填充这个饼图块。是否可以实现,如果可以,如何操作?


包含什么的饼图部分?这些形状的容器是什么? - Mike Strobel
那个饼看起来很奇怪,为什么不直接使用WPF工具包并使用图表控件呢?但是,如果你只是把你的“矩形”称作“片”,那么只需要使用Fill="Color"就可以了。 - Chris W.
不确定那个饼状图形看起来是什么样子的。椭圆形不够吗?还是你想要某种弧形(不是完整的椭圆形)? - King King
1个回答

5

为了让您开始...

<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>

谢谢,这让我找到了正确的方向。最终我找到了这篇博客文章,几乎就是我想要的:http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html - Paul Michaels

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接