Setting ClassBreaksInfo in ClassBreaksRenderer

1047
3
05-19-2010 09:58 AM
ScottBridwell
New Contributor III
I'm trying to dynamically apply a renderer to a feature layer without iterating and applying a symbol to each graphic. Unfortunately, the ClassBreaksRenderer.Classes property (ObservableCollextion<ClassBreaksInfo>) is read only. Does anybody know how to get around this or is not possible to  make changes to a class breaks renderer?

thanks,
scott
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
The ClassBreaksRenderer.Classes property is read-only, but the underlying ObservableCollection can be modified :
ClassBreaksRenderer.Classes.Add(myClassBreakInfo) or
ClassBreaksRenderer.Classes.Remove(myClassBreakInfo)
0 Kudos
SantoshV
New Contributor II
Hey runtime is good I tried doin it like this

classBreakInfo.MinimumValue = Convert.ToInt32(strLeftWidth.Substring(1, intIndex));
classBreakInfo.MaximumValue = Convert.ToInt32(strRightWidth.Substring(1, intIndex));
classBreakInfo.Symbol = LayoutRoot.Resources["LineSymbolRed"] as Symbol;
MyClassBreaksRenderer.Classes.Add(classBreakInfo);
graphicsLayer.Renderer = MyClassBreaksRenderer;


but my graphic layer is not returning to the map what am I missing here ?
0 Kudos
JenniferNery
Esri Regular Contributor
It's hard to tell where the problem could be without knowing how the ClassBreaksRenderer was created. It might be that the Attribute of ClassBreaksRenderer does not match an OutField in your FeatureLayer or the symbol does not match the geometry type of the layer.

http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#FeatureLayerRendering
The equivalent code-behind of the XAML in this sample is as follows:
private void FeatureLayer_Initialized(object sender, System.EventArgs e)
{
 FeatureLayer layer = sender as FeatureLayer;   
 ClassBreaksRenderer classBreaksRenderer = new ClassBreaksRenderer()
 {
  Attribute = "POP07_SQMI"
 };
 classBreaksRenderer.Classes.Add(
  new ClassBreakInfo() 
  { 
   MinimumValue = 0d, 
   MaximumValue = 50d, 
   Symbol = this.LayoutRoot.Resources["LowFillSymbol"] as Symbol
  }
 );

 classBreaksRenderer.Classes.Add(
  new ClassBreakInfo()
  {
   MinimumValue = 50d,
   MaximumValue = 200d,
   Symbol = this.LayoutRoot.Resources["MediumFillSymbol"] as Symbol
  }
 );

 classBreaksRenderer.Classes.Add(
  new ClassBreakInfo()
  {
   MinimumValue = 200d,
   MaximumValue = 5000d,
   Symbol = this.LayoutRoot.Resources["HighFillSymbol"] as Symbol
  }
 );
 layer.Renderer = classBreaksRenderer;   
}
0 Kudos