Почему этот код не работает.
Почему segment = new PolyLineSegment(); имеющий ссылку на массив точек пустой, которые заполняются, но его свойство segment.Points.Сount=0???
void init(){ geometry = new PathGeometry();
pointsCollection=new();
segment = new PolyLineSegment();
segment.Points = pointsCollection;
fig = new PathFigure();// pointsCollection[0], new[] { segment }, false);
fig.Segments.Add(segment);
fig.StartPoint = pointsCollection[0];
fig.IsClosed = false;
geometry.Figures.Add(fig);
}
void push(Point p){
// почему geometry не обновляет значения точек?
pointsCollection.Add(p);
}
void draw(DrawingContext g){
//
g.DrawGeometry(null, penDraw, geometry);
}
// так работает как надо
void fDrawingContext g(){
segment = new PolyLineSegment();
segment.Points = pointsCollection;
fig = new PathFigure();// pointsCollection[0], new[] { segment }, false);
fig.Segments.Add(segment);
fig.StartPoint = pointsCollection[0];
fig.IsClosed = false;
geometry.Figures.Add(fig);
g.DrawGeometry(null, penDraw, geometry);
}