Select to view content in your preferred language

UniqueValueRenderer change polygon fill color dynamically

4241
29
07-15-2010 08:16 PM
xariaD
by
Occasional Contributor
How to change the fill color of a particular polygon at runtime?
0 Kudos
29 Replies
DominiqueBroux
Esri Frequent Contributor
This thread http://forums.arcgis.com/threads/6481-Dynamically-change-color-of-a-symbol?highlight=symbol+binding could help (by replacing markersymbol by fillsymbol).
0 Kudos
xariaD
by
Occasional Contributor
My problem lies in retrieving the polygon from feature layer.
The feature layer has multiple polygons. Also, I have a table stored in SQL database which stores status values of these polygons.
When the status changes the color should change.
So suppose if for polygon 1 status is 1 color is green,
then when the status for polygon changes to 0 the color should be red.

How do I apply the color change to polygon 1wiithout changing the color of other polygons?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Looks like a standard usage of an UniqueValueRenderer.

Create two symbols (in your resources), one green and one red.
In your UniqueValueRenderer, affect the red symbol to value 0 and the green one to value 1.

The symbol will automatically change when the status value changes.

See sample http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#RenderersXAML
0 Kudos
xariaD
by
Occasional Contributor
So does that mean Status should be defined as an attribute of the feature?

But the status changes dynamically, and the status is passed to the WPF application via WCF operation.
So how to assign the new attribute value?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
So does that mean Status should be defined as an attribute of the feature?

Yes, it's the easiest way.

But the status changes dynamically, and the status is passed to the WPF application via WCF operation.
So how to assign the new attribute value?

You can add attributes at runtime :
 
if (graphic.Attributes.ContainsKey("Status"))
  graphic.Attributes["Status"] = status;
else
  graphic.Attributes.Add("Status", status);
0 Kudos
xariaD
by
Occasional Contributor
Yes, it's the easiest way.


You can add attributes at runtime :
 
if (graphic.Attributes.ContainsKey("Status"))
  graphic.Attributes["Status"] = status;
else
  graphic.Attributes.Add("Status", status);


When should the attribute be added? During layer Initialization? Or do I need to add a task?
0 Kudos
xariaD
by
Occasional Contributor
The attributes are not displayed in the WPF application.
I have attributes like ObjectId, RefName, text, txtMemo, status
but the feature layer has attribute
RefName, Shape_Length and Shape_area
😞

Ans as usual the web application is showing the attributes under the identify feature correctly!!!!!
:mad:
0 Kudos
xariaD
by
Occasional Contributor
I have added attributes to the map in ArcMap, and the REST service also displays all the attributes as fields. The web application displays all attributes in the identify table.

But WPF Application does not display those attributes. WHAT could be the reason? What should I check please guide me.
0 Kudos
dotMorten_esri
Esri Notable Contributor
Did you set the OutFields property on the FeatureLayer?
0 Kudos