With this code:
.xaml
.cs
Why does executing "gCanvasPlotTop.Children.Add(poXY)" result in this message "System.InvalidOperationException: 'Specified element is already the logical child of another element. Disconnect it first.'"
The name "gCanvasPlotTop" is only in the .xaml.
.xaml
C#:
<Canvas x:Name="gCanvasPlotTop"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="0,0,0,0"
Width="500"
Height="150" />
.cs
C#:
for (int ii = 0; ii < iNumOfPoints; ii++) {
var pointResult = new Point {
X = (listPoints[ii].X - dXmin) * canvas.Width / dPlotWidth,
Y = canvas.Height - (listPoints[ii].Y - dYmin) * canvas.Height / dPlotHeight
};
poXY.Points.Add(pointResult);
}
gCanvasPlotTop.Children.Add(poXY);
Why does executing "gCanvasPlotTop.Children.Add(poXY)" result in this message "System.InvalidOperationException: 'Specified element is already the logical child of another element. Disconnect it first.'"
The name "gCanvasPlotTop" is only in the .xaml.