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?
if (graphic.Attributes.ContainsKey("Status")) graphic.Attributes["Status"] = status; else graphic.Attributes.Add("Status", status);
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);
Did you set the OutFields property on the FeatureLayer?
<esriSymbols:SimpleFillSymbol x:Key="MyYellowFillSymbol" Fill="YellowGreen" BorderBrush="Transparent" BorderThickness="2" /> <esriSymbols:SimpleFillSymbol x:Key="MyRedFillSymbol" Fill="Red" BorderBrush="Transparent" BorderThickness="2" /> <esri:UniqueValueRenderer x:Key="MyUniqueValueRenderer" Attribute="Status" > <esri:UniqueValueRenderer.Infos> <esri:UniqueValueInfo Value="Off" Symbol="{StaticResource MyRedFillSymbol}" /> <esri:UniqueValueInfo Value="On" Symbol="{StaticResource MyYellowFillSymbol}"/> </esri:UniqueValueRenderer.Infos> </esri:UniqueValueRenderer>
<esri:FeatureLayer ID="towers" Url="http://MyMapURL/MapServer/0" Where="1=1" Renderer="{StaticResource MyUniqueValueRenderer}" MouseLeftButtonDown="FeatureLayer_MouseLeftButtonDown"> <esri:FeatureLayer.OutFields> <sys:String>RefName</sys:String> <sys:String>Status</sys:String> <sys:String>Text</sys:String> </esri:FeatureLayer.OutFields> </esri:FeatureLayer>
So when I set the graphic.Attributes["status"] to newstatus value, it is not rendered.
<esri:UniqueValueRenderer x:Key="MyUniqueValueRenderer" Attribute="Status" >
private void FeatureLayer_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e) { Graphic feature = e.Graphic; feature.Attributes["Status"] = "On"; }
You can also listen to EndSaveEdits and SaveEditsFailed to see if a graphic is updated.
<UserControl.Resources> <esri:SimpleFillSymbol x:Key="MyYellowFillSymbol" Fill="YellowGreen" BorderBrush="Transparent" BorderThickness="2" /> <esri:SimpleFillSymbol x:Key="MyRedFillSymbol" Fill="Red" BorderBrush="Transparent" BorderThickness="2" /> <esri:UniqueValueRenderer x:Key="MyUniqueValueRenderer" Attribute="symbolname"> <esri:UniqueValueRenderer.Infos> <esri:UniqueValueInfo Value="Residential - Very Low Density" Symbol="{StaticResource MyRedFillSymbol}" /> <esri:UniqueValueInfo Value="Residential - Low Density" Symbol="{StaticResource MyYellowFillSymbol}" /> </esri:UniqueValueRenderer.Infos> </esri:UniqueValueRenderer> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <esri:Map x:Name="MyMap"> <esri:ArcGISTiledMapServiceLayer Url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> <esri:FeatureLayer ID="towers" Url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/LandusePlanning/FeatureServer/2" Where="1=1" Renderer="{StaticResource MyUniqueValueRenderer}" EndSaveEdits="FeatureLayer_EndSaveEdits" SaveEditsFailed="FeatureLayer_SaveEditsFailed" MouseLeftButtonDown="FeatureLayer_MouseLeftButtonDown"> <esri:FeatureLayer.OutFields> <sys:String>symbolname</sys:String> </esri:FeatureLayer.OutFields> </esri:FeatureLayer> </esri:Map> </Grid>
private void FeatureLayer_MouseLeftButtonDown(object sender, ESRI.ArcGIS.Client.GraphicMouseButtonEventArgs e) { Graphic g = e.Graphic; string currentValue = (string) g.Attributes["symbolname"]; if(currentValue.Contains("Very")) g.Attributes["symbolname"] = "Residential - Low Density"; else g.Attributes["symbolname"] = "Residential - Very Low Density"; } private void FeatureLayer_EndSaveEdits(object sender, ESRI.ArcGIS.Client.Tasks.EndEditEventArgs e) { } private void FeatureLayer_SaveEditsFailed(object sender, ESRI.ArcGIS.Client.Tasks.TaskFailedEventArgs e) { }
I got it working, not by using UniqueValueRenderer though.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.