我正在尝试动态地向Grid添加一些路径,但这会产生一个导致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未处理
答案 0 :(得分:4)
我看到myGeometryGroup.Children.Add(myGeometryGroup);
,你概率
会做的
myGeometryGroup.Children.Add(myEllipseGeometry);