Select to view content in your preferred language

Dismiss Customized Content Control and Disable the function?

821
6
10-04-2010 06:54 AM
ducksunlimited
Deactivated User
Hi All,

I use a customized content control for Identify tool. How to clear all the graphics and disable the Identify funtion after I dismiss/close the control panel. Appreciate the help,

Chris
0 Kudos
6 Replies
JenniferNery
Esri Regular Contributor
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
}
0 Kudos
ducksunlimited
Deactivated User
Thanks for the reply!

I used a customized user control (windows Panel). when I put these codes, it tells me i am missing use directive for MyMap. How to fix it? thanks,

Chris


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
}
0 Kudos
JenniferNery
Esri Regular Contributor
"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.
0 Kudos
ducksunlimited
Deactivated User
"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.


I don't think i described the problem clearly.

I have two xaml files - MainPage and WindowPanel. MyMap is in MainPage.xaml, not in WindowPanel.xaml. Now How can i use MyMap control in WindowPanel.xaml.cs file?

Thanks
0 Kudos
JenniferNery
Esri Regular Contributor
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...
0 Kudos
ducksunlimited
Deactivated User
Where to add <local:MainPage x:Name="MainPage"/>?

appreciate your help!

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...
0 Kudos