Select to view content in your preferred language

Dynamic Symbology

1354
2
09-28-2010 08:33 AM
ShaneBuscher
Frequent Contributor
I have a requirement to support custom symbology for each user based on attribute values.  I am trying to use the UniqueValueRenderer to accomplish this, but I ran into a problem where UniqueValueRender.Infos property is read-only.  This limits my ability in code to set up user-defined symbology. 

Typically I'm seeing UniqueValueRender defined statically as a resource as shown below.  I am trying to use code because I can't possibly statically define all the possible permutations between color, fill and attribute values. 

Is there any way around this?

<Grid.Resources>
    <esriSymbols:SimpleFillSymbol x:Name="MyGreenFillSymbol" Fill="#6600FF00" BorderBrush="Green"       
      BorderThickness="2" />
    <esriSymbols:SimpleFillSymbol x:Name="MyYellowFillSymbol" Fill="#66FFFF00"
      BorderBrush="Yellow" BorderThickness="2" />
    <esriSymbols:SimpleFillSymbol x:Name="MyRedFillSymbol" Fill="#66FF0000" BorderBrush="Red"
      BorderThickness="2" />
    <esri:UniqueValueRenderer x:Name="MyUniqueValueRenderer" Attribute="STATE_NAME" >
        <esri:UniqueValueRenderer.Infos>
     <esri:UniqueValueInfo Value="California" Symbol="{StaticResource MyGreenFillSymbol}" />
     <esri:UniqueValueInfo Value="New York" Symbol="{StaticResource MyYellowFillSymbol}" />
     <esri:UniqueValueInfo Value="Kansas" Symbol="{StaticResource MyRedFillSymbol}" />
         </esri:UniqueValueRenderer.Infos>
    </esri:UniqueValueRenderer>
</Grid.Resources>
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
UniqueValueRender.Infos property is read-only but you can add/remove items to it.

 
myUniqueValueRenderer.Infos.Add(new UniqueValueInfo() { Value="California", Symbol=.......});
0 Kudos
ShaneBuscher
Frequent Contributor
Thanks.  That was my oversight...
0 Kudos