I have this xml tag code which looks as follows:
<FeatureLayerExtension>
<WhereString>(ZONE ='A') or (ZONE ='V')</WhereString>
<OutFields>ZONE</OutFields>
<UniqueDataCount>2</UniqueDataCount>
<UniqueValueRenderer>
<SimpleFillSymbol Color="White" Fill="Yellow" Width="1.5" Fvalue ='A' />
<SimpleFillSymbol Color="White" Fill="Green" Width="1.5" Fvalue ='V' />
</UniqueValueRenderer>
</FeatureLayerExtension>
I use this in .Cs page with help of serialization in the following way:
if (projectMap.FeatureLayerConfig != null && projectMap.FeatureLayerConfig.UniqueValueRenderer != null)
{
agisFeatureLayer.RendererTakesPrecedence = true;
var renderer = new UniqueValueRenderer();
renderer.Field = projectMap.FeatureLayerConfig.OutFields;
for (int i = 0; i <= projectMap.FeatureLayerConfig.UniqueDataCount - 1; i++)
{
UniqueValueInfo info = new UniqueValueInfo();
if (projectMap.FeatureLayerConfig.UniqueValueRenderer.SimpleFillSymbol != null)
{
var fill = GlobalConfigs.ColorToStringDic[projectMap.FeatureLayerConfig.UniqueValueRenderer.SimpleFillSymbol.Fill];
var borderBrush = GlobalConfigs.ColorToStringDic[projectMap.FeatureLayerConfig.UniqueValueRenderer.SimpleFillSymbol.Color];
var borderThickness = projectMap.FeatureLayerConfig.UniqueValueRenderer.SimpleFillSymbol.Width;
var fillSymbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(fill), BorderBrush = new SolidColorBrush(borderBrush), BorderThickness = borderThickness };
info.Value = PojectMap.FeatureLayerConfig.UniqueValueRenderer.UniqueValueInfo.SimpleFillSymbol.Fvalue;
info.Symbol = fillSymbol;
renderer.Infos.Add(info);
}
}
agisFeatureLayer.Renderer = renderer;
}
}
For the second child element SimpleFillSymbol of Fvalue 'V' I unable to get it show during the rendering. The SimpleFillSymbol value 'A' renders twice as shown in the table of contents..How can i make the second fill symbol to show by iterating through the child elements
Code for the serilaization of the xml to object:
using System.Xml.Serialization;
using System.Windows.Media;
namespace My.GIS.Viewer.Configuration.Map
{
public partial class PortalFeatureLayer
{
[XmlElement(typeof(uvRendererConfig), ElementName = "UniqueValueRenderer")]
public uvRendererConfig UniqueValueRenderer { get; set; }
[XmlElement(typeof(int), ElementName = "UniqueDataCount")]
public int UniqueDataCount { get; set; }
}
public class uvRendererConfig
{
[XmlElement(typeof(mySimpleFillSymbol), ElementName = "SimpleFillSymbol")]
public mySimpleFillSymbol SimpleFillSymbol { get; set; }
[XmlElement(typeof(mySimpleMarkerSymbol), ElementName = "SimpleMarkerSymbol")]
public mySimpleMarkerSymbol SimpleMarkerSymbol { get; set; }
[XmlElement(typeof(mySimpleLineSymbol), ElementName = "SimpleLineSymbol")]
public mySimpleLineSymbol SimpleLineSymbol { get; set; }
}
public class mySimpleFillSymbol : SymbolBase {
[XmlAttribute(AttributeName = "Fill")]
public string Fill { get; set; }
[XmlAttribute(AttributeName = "FieldValue")]
public string FieldValue { get; set; }
}
public class SymbolBase
{
[XmlAttribute(AttributeName = "Color")]
public string Color { get; set; }
[XmlAttribute(AttributeName = "Width")]
public double Width { get; set; }
}
}
You need to change the classes for XML deserialization as follows:
Use the following code to fetch the list of SimpleFillSymbol objects
Try using linq:
Will return both the Fvalue attributes for the element SimpleFillSymbol