0

我正在尝试向网格动态添加一些路径,但这会生成一个无限循环,从而导致 SO。

    private void SubLayout_Loaded(object sender, RoutedEventArgs e)
    {
        GeometryGroup myGeometryGroup = new GeometryGroup();
        EllipseGeometry myEllipseGeometry = new EllipseGeometry();
        myEllipseGeometry.Center = new Point(100, 41.5);
        myEllipseGeometry.RadiusX = 5;
        myEllipseGeometry.RadiusY = 5;
        myGeometryGroup.Children.Add(myGeometryGroup);
        points.Data = myGeometryGroup;
    }

XAML:

   <Path x:Name="points" Fill="Gold" Stroke="Black" 
StrokeThickness="1"> </Path>

错误:

System.StackOverflowException 未处理

4

1 回答 1

4

我明白 了myGeometryGroup.Children.Add(myGeometryGroup);,你可能 会做

myGeometryGroup.Children.Add(myEllipseGeometry);
于 2012-04-22T20:46:54.087 回答