Can't add Graphic to a GraphicsLayer

602
0
03-24-2017 07:09 AM
ShaningYu
Frequent Contributor

This is .Net (Silverlight) program.  I want to add a Graphic item to a GraphicsLayer.  The related code is listed below

            GraphicsLayer newGLyr = new GraphicsLayer();
            for (int i = 0; i < gLayer.Graphics.Count; i++)     {
                Graphic g = gLayer.Graphics;
                if (!isDuplicate(newGLyr, g))
                    newGLyr.Graphics.Add(g);
            }

However, I got the runtime error:

Specified argument was out of the range of valid values.  Parameter name: Graphic is already associated with another layer.

How can this be fixed?  Thanks.

Tags (1)
0 Kudos
0 Replies