【问题标题】:Fill for EllipseGeometry填充椭圆几何
【发布时间】:2015-11-06 10:54:20
【问题描述】:

我需要将一些绘图(三角形和圆形)作为一个对象(将其设置为内容)。三角形应该填充,圆形不应该填充颜色。问题是 EllipseGeometry 没有 IsFilled 属性。如果我删除 Path 处的 Fill 属性,则两者都不会被填充。我怎样才能填充 PathFigure 而不是填充 Ellipse 将它们都放在一个 Path 父级中?

<Path Stroke="#FFF633FF"
      StrokeThickness="1"
      Fill="#FFF633FF">
    <Path.Data>
        <GeometryGroup>
            <EllipseGeometry Center="6,0"
                             RadiusX="4"
                             RadiusY="4">
            </EllipseGeometry>
            <PathGeometry >
                <PathGeometry.Figures>
                    <PathFigure StartPoint="6,-15" 
                                IsClosed="True">
                        <LineSegment Point="1,-25" />
                        <LineSegment Point="11,-25" />
                    </PathFigure>
                </PathGeometry.Figures>
            </PathGeometry>
        </GeometryGroup>
    </Path.Data>
</Path>

【问题讨论】:

    标签: wpf path geometry


    【解决方案1】:

    一个简单的技巧是将 EllipseGeometry 替换为具有两个 ArcSegment 的未填充 PathGeometry:

    <PathGeometry >
        <PathGeometry.Figures>
            <PathFigure StartPoint="2,0" IsFilled="False">
                <ArcSegment Point="10,0" Size="4,4" />
                <ArcSegment Point="2,0" Size="4,4" />
            </PathFigure>
        </PathGeometry.Figures>
    </PathGeometry>
    

    【讨论】:

      【解决方案2】:

      几何的全部意义在于描述一个形状。描边和填充总是取自拥有的路径,因为路径负责绘制形状。所以你问的是不可能的。您需要在这里使用两个路径。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-03-13
        • 1970-01-01
        • 2011-03-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-19
        相关资源
        最近更新 更多