Select to view content in your preferred language

Best way to add the attributes to a graphic

1025
3
Jump to solution
03-23-2012 12:31 PM
CraigPatterson
Regular Contributor
In my application, I add a graphic to a featurelayer based on a buffered line.  My vision is that after the graphic is added, the attribute EditorWidgets attribute editor opens so the user may add the necessary attributes. 

The first issue  is that after the graphic is added, the only attribute is the GlobalID field.  Is there a way to loop through the featurelayers attributes to add them to the graphic? 

The next issue is, how do I open the attribute editor with the new graphic loaded?

Here's my method to add the graphic to the featurelayer.

void GeometryService_BufferLineCompleted(object sender, GraphicsEventArgs args) { // Create new graphic to contain geometry of buffer Graphic bufferGraphic = new Graphic(); bufferGraphic.Geometry = args.Results[0].Geometry; // Retrieve the Projects featurelayer from the application FeatureLayer projects = MyMap.Layers["Projects_Edit"] as FeatureLayer; // Add the buffered line graphic to the featurelayer if (projects != null) { projects.Graphics.Add(bufferGraphic); } } 


Thanks,

Craig Patterson
0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor
Cool. I'm glad that worked for you.

You can use ChildWindow as in Post# 5 & 7 from this related thread: forums.arcgis.com/threads/43088-Insert-new-feature-in-a-feature-service-layer-via-a-geocode-result. This is essentially the same code TemplatePicker run when ShowAttributesOnAdd is true.

View solution in original post

0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
Please refer to post# 2 in this thread: http://forums.arcgis.com/threads/44168-Adding-a-point-to-a-featurelayer-using-coordinates.

You can add attributes to the graphic before adding it to the layer. You can also use FeatureDataForm as in this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataForm.

EditorWidget use the same control and show it in a ChildWindow. If you were to use EditorWidget/TemplatePicker to add the graphic, there is ShowAttributesOnAdd property that you can set to True. Whenever you add a new feature, a FeatureDataForm is displayed. As seen in this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitEditorWidget
0 Kudos
CraigPatterson
Regular Contributor
Thanks Jennifer.  Your suggestion to add the attributes worked like a charm. 

I still need to figure out how to make the attribute form open when I add the graphic.  My EditorWidget has the ShowAttributesOnAdd set to true but it doesn't open when I add the buffered graphic.  Is there a way to manually open the attribute editor?

Thanks,

Craig
0 Kudos
JenniferNery
Esri Regular Contributor
Cool. I'm glad that worked for you.

You can use ChildWindow as in Post# 5 & 7 from this related thread: forums.arcgis.com/threads/43088-Insert-new-feature-in-a-feature-service-layer-via-a-geocode-result. This is essentially the same code TemplatePicker run when ShowAttributesOnAdd is true.
0 Kudos