Select to view content in your preferred language

Changing Feature Symbol

645
1
02-16-2011 03:10 AM
BettyKeren
New Contributor
Hi,

Is there an option to change the render for only one feature on the map, without changing the feature layer renderer.

For exmple to change the polyline color on mouse over/click.

Thanks
Betty
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
You have to choose one or the other as noted in this help doc: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.GraphicsLa....

You can, however try to clone the existing renderer as defined by the service and modify the symbol base on your preference. Your custom symbol will then have VisualStates for MouseOver or Selected.
void l_Initialized(object sender, EventArgs e)
{
 FeatureLayer l = sender as FeatureLayer;
 if (l.Renderer is UniqueValueRenderer)
 {
  var current = l.Renderer as UniqueValueRenderer;
  var renderer = new UniqueValueRenderer() { Attribute = current.Attribute };
  foreach (var info in current.Infos)
  {
   var newInfo = new UniqueValueInfo()
   {
    Description = info.Description,
    Label = info.Label,
    Value = info.Value,
    //TODO: clone existing symbol or overwrite with new symbol
    Symbol = this.LayoutRoot.Resources["MyCustomSymbol"]    };
   renderer.Infos.Add(newInfo);
  }
  l.Renderer = renderer;
 }
}


This sample shows how to create custom symbols: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#CustomSymbols
0 Kudos