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

标签 c# wpf xaml

我有以下 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>

我想做的是用颜色填充其中包含的饼图。这可能吗?如果可以,我该怎么做?

最佳答案

让您开始...

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

关于c# - 如何在 WPF XAML 中填充饼形区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26285076/

相关文章:

c# - 如何从窗口内的另一个类调用方法?

c# - WPF 中的模糊转换文本

c# - 防止通过键盘 XAML 突出显示/选择?

c# - WPF TextBox Extension无法使用MahApps TextBoxHelper

c# - 无法在 Visual Studio 2017 Enterprise MSTest Selenium 单元测试 C# 中找到/添加订购的测试项目到我的项目

c# - 将 .rtf 文件从资源加载到 RichTextBox

c# - 返回一个常量字符串数组

C# 使用 FindWindowEx 按名称和序号获取子句柄

c# - 在 WPF 的静态资源中存储具有内容的元素

c# - 关闭 MessageDialog 后聚焦 WebView