I getting an error for the following and have no clue what it means.
The error is a run time error: "Speficied argument was out of the range of valid values. Parameter name: Graphic is already associated with another layer."
The error points to this line: graphicsLayerTEMP.Graphics.Insert(0, thisgraphic);
Thanks in advance for any help.
private void FindDetailsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
DataGrid dataGrid = sender as DataGrid;
int selectedIndex = dataGrid.SelectedIndex;
Graphic thisgraphic = (Graphic)FindDetailsDataGridOHI.SelectedItem;
if (selectedIndex > -1)
{
thisgraphic.Symbol = LayoutRoot.Resources["griddataPointRendererTEMP"] as ESRI.ArcGIS.Client.Symbols.Symbol;
// GridDataSelectedGraphicTEMP is a separate graphic layer just to highlight the selected point
GraphicsLayer graphicsLayerTEMP = MyMap.Layers["GridDataSelectedGraphicTEMP"] as GraphicsLayer;
thisgraphic.Geometry.SpatialReference = MyMap.SpatialReference;
graphicsLayerTEMP.ClearGraphics();
graphicsLayerTEMP.Graphics.Insert(0, thisgraphic);
if ( myCursorAt == "TABLE" ) MyMap.PanTo(graphicsLayerTEMP.FullExtent.Extent);
}
}