Hi!I've created an add-in to query FeatureLayers and ArcGISDynamicMapServiceLayers.Querying the different kinds of layers works great, but I've run into a problem and I can't seem to find a solution.When the user queries a layer based on certain criteria, I bind the returned FeatureSet to a datagrid. The user can then select which rows they want to display in the map by marking them in the datagrid and then clicking a button that adds them to the map (in a layer that is named the same as the queried sub layer) and zooms to the result. Clicking a Graphic object in the datagrid when it is displayed in the map also changes symbology.When I add each Graphic to the layer, I first check if the layer already contains the graphic: GraphicsLayer layer = LayerExists(layerName); if (!layer.Graphics.Contains(g)) layer.Graphics.Add(g);
The function LayerExists checks if the selected layer name already exists, if it does, it is returned. If it doesn't exist, it is created.If I try to add the same Graphic twice (without closing the window that the tool opens), layer.Contains(g) works fine.However, if I close the window, open it up again, perform the same query and try to add the same Graphic object, it adds a duplicate to that layer.I've tried solving this by comparing geometries: bool layerContainsGraphic = false; foreach (Graphic graphicInLayer in layer.Graphics) { if (graphicToAdd.Geometry == graphicInLayer.Geometry) layerContainsGraphic = true; } if (!layerContainsGraphic) layer.Graphics.Add(graphicToAdd);
but I still encounter the same problem, layerContainsGraphic is never true. The geometries never match, even though they are identical; same WKID, same extent etc. I then tried using GetHashCode, and the geometries return different hash codes. Why is that?I also tried comparing attribute collections, but it yields the same result as above.Sorry for the wall of text, please tell me if something in my explanation is unclear and I'll try to be clearer.Best regardsJohan