Editor buttons not enabled

641
3
02-23-2011 06:15 AM
AndrewWhite
New Contributor
I have copied the code from the Feature Layer Selection example.  None of the buttons become enabled, no matter what I try.  Any suggestions?

I've changed the URLs to point to services on my server.

My services use Active Directory authentication so I am adding the layers to the map in code behind so I can set the layer Credentials = CredentialCache.DefaultCredentials.

Other than that, my code is identical to the sample.  Do I have to enable something on my arcgis server?  Will the editor not work if I add the layers in code-behind, or if they use AD Authentication?

Help!
0 Kudos
3 Replies
AndrewWhite
New Contributor
I answered my own question...

If you're adding your layers to the map in code-behind, you have to add your Editor after you add your layers.  I'm guessing my problem occurred because I was setting my Editor.LayerIDs to a layer that didn't exist on the map yet.
0 Kudos
JenniferNery
Esri Regular Contributor
If you plan on adding layers dynamically and need all GraphicsLayers and FeatureLayers from your Map.Layers to use the same Editor, it is sufficient to supply only Editor.Map property. If you wish to include or exclude some layers, you can also supply the Editor.LayerIds property.

Actually in the sample link you provided.. if you are using WPF, setting Editor.Map property through Element binding is not supported.
<esri:Editor x:Key="MyEditor" Map="{Binding ElementName=MyMap}" LayerIDs="CensusDemographics" SelectionMode="Rectangle" ContinuousMode="True" />

You need to set this property in code-behind:
Editor editor = this.LayoutRoot.Resources["MyEditor"] as Editor;
editor.Map = this.MyMap;


You can still use LayerIDs property if you wish to include only specific layers from your map. When you create the layer in code-behind, you just need to set ID property to match this.
For example
FeatureLayer l = new FeatureLayer()
{
 ID = "CensusDemographics",
 Url = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0"
};
MyMap.Layers.Add(l);
0 Kudos
AndrewWhite
New Contributor
Thank you, very much!
0 Kudos