Combining LineGeometry with EllipseGeometry (in code, not XAML)

后端 未结 1 882
鱼传尺愫
鱼传尺愫 2021-01-19 16:53

I\'m trying to create a custom shape with WPF. For starters I was just trying to create a simple line, that has a circle at each end (I know there are LineCaps, but that\'s

相关标签:
1条回答
  • 2021-01-19 17:15

    Your LineGeometry objects will vanish if you try to Union them. From MSDN:

    The GeometryCombineMode property specifies how the two geometries will be combined. Note that CombinedGeometry combines the area specified by two geometries, so geometries that do not have area (such as LineGeometry) disappear when combined.

    You can use GeometryGroup:

    GeometryGroup combined = new GeometryGroup();
    combined.Children.Add(ellipse1);
    combined.Children.Add(ellipse2);
    combined.Children.Add(line);
    

    or you can use CombinedGeometry on the ellipse objects first, and then group that together with the line using GeometryGroup.

    0 讨论(0)
提交回复
热议问题