GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; if (layer != null) layer.Graphics.Clear(); // or layer.ClearGraphics();
Are you referring to this sample? http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify
If yes, you can clear the graphics layer by doing the following:GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; if (layer != null) layer.Graphics.Clear(); // or layer.ClearGraphics();
where "MyGraphicsLayer" is the ID of the layer whose graphics you need to clear.
Also to ensure that IdentifyTask is no longer performed on MouseClick, you can either
* unsubscribe to this event so succeeding MouseClicks do not perform an IdentifyTask, or
this.MyMap.MouseClick -= QueryPoint_MouseClick;
* use a private boolean to denote if IdentifyTask need to be created and check if that is true/false before performing an IdentifyTask.
bool identifyTaskEnabled = false; //set to true/false
private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
{
if (!identifyTaskEnabled ) return; // to skip the code that follows
... //IdentifyTask code goes here
}
"MyMap" in the code I posted is the name of the map from the sample. You might have renamed the map to something else, you should use that name instead.
<local:MainPage x:Name="MainPage"/>
Oh so MyMap belongs to MainPage.xaml but you need to update it's properties in WindowPanel.xaml. Does WindowPanel contain MainPage? If yes, you probably have something like:<local:MainPage x:Name="MainPage"/>
Provide this instance a name so you can access MyMap by using this.MainPage.MyMap...