Select to view content in your preferred language

How to reference the selected graphic in Edit mode?

673
1
03-21-2011 01:36 PM
weiliang
Deactivated User
Hi there,

Under edit mode by using Editor, when I select a feature, the feature is highlighted with Cyan color. Is there any way that I can change this default highlighted fill color and the border color?

I have another question about the legend. In my code, how could I get the color or the symbology for a certain layer from a map service?

Thanks,

Wei
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
If the service used in your FeatureLayer defines its own renderer, you can set FeatureLayer.SelectionColor when you define the layer.http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureLay...

To get the symbol color, you have the following options (see comments).
private void FeatureLayer_Initialized(object sender, System.EventArgs e)
{
 FeatureLayer layer = sender as FeatureLayer;
 if (layer == null || layer.Renderer == null) return;
 Symbol symbol = null;
 Brush brush = null;
 //Determine type of Renderer to get symbol
 if (layer.Renderer is SimpleRenderer)
  symbol = (layer.Renderer as SimpleRenderer).Symbol;
 //or, pass graphic to layer.Renderer.GetSymbol()
 if (layer.Graphics != null && layer.Graphics.Count > 0)
  symbol = layer.Renderer.GetSymbol(layer.Graphics[0]);
 //if not FeatureService.Symbols, you can do...
 if (symbol is SimpleMarkerSymbol)
  brush = (symbol as SimpleMarkerSymbol).Color;
}
0 Kudos