Hi Ravi, When copying the graphic you need to use the Clone() method or you will have two references to the same graphic, when you try to add the second graphic reference to another GraphicsLayer our API will throw an exception because it knows that the graphic belongs to a different GraphicsLayer already. If you want to copy to a new GraphicsLayer you can make a new instance like below.Graphic myGraphic = new Graphic();myGraphic.Geometry = selectedGraphic.Geometry.Clone();My question to you is why are you going to this length in the first place. If you are using FeatureLayer with graphics comming from a FeatureServer then a selection color is built into the FeatureLayer and all you have to do is set myGraphic.Selected = true and the renderer associated with the FeatureLayer will change the selection color for you. then when you set MyGraphic.Selected = false the color will change back. If you are using a GraphicsLayer you will need to add selection state to your symbols using this SDK Samplehttp://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SelectGraphics
Ah, your using our Silverlight API v1.x, that makes a big difference. If you ever get the chance to upgrade to our current version a lot of what you are trying to do would be a lot easier to accomplish. Glad you got it all worked out.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.