Select to view content in your preferred language

I need to edit the attributes of a graphic

3857
2
06-18-2012 12:46 PM
Labels (1)
JessicaLott1
New Contributor
All I need to do is edit the attributes of a graphic so that when the user want to change information about the graphic is will show up in the maptip. Here is my Code and XAML.


//Following code creates a new graphic and adds the information that I want to save about it to a list that I have created.
Graphic graphic = new Graphic()
                        {
                            Symbol = AddressLayout.Resources["LotRenderer"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                            Geometry = candidate.Location
                        };
                        string address1 = Address.Text;
                        string address2 = String.Format("{0}, {1} {2}", City.Text, State.Text, Zip.Text);

                        addressCombined = String.Format("{0},{1},{2},{3}", Address.Text, City.Text, State.Text, Zip.Text);


                        ObjectProperties record = new ObjectProperties
                        {
                            ObjectNumber = txtObjectNumber.Text,
                            ObjectComments = txtComments.Text,
                            ObjectAddress = addressCombined,
                        };

                        Properties.Add(record);

                        graphic.Attributes.Add("MeterNum", record.ObjectNumber);
                        graphic.Attributes.Add("Comment", record.ObjectComments);
                        graphic.Attributes.Add("Address1", address1);
                        graphic.Attributes.Add("Address2", address2);


FeatureLayer graphicsLayer = MyMap.Layers["WaterMeterLayer"] as FeatureLayer;
                graphicsLayer.Graphics.Add(graphic);

//Here is the set up for my list.

class ObjectProperties
        {
            public string ObjectNumber { get; set; }
            public string ObjectComments { get; set; }
            public string ObjectAddress { get; set; }

          
        }

        List<ObjectProperties> Properties = new List<ObjectProperties>();


//Here is my XAML

  <esri:FeatureLayer ID="WaterMeterLayer"
                               Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map..."
                               AutoSave="True"
                               Mode="OnDemand"
                               Renderer="{StaticResource WaterMeterRenderer}"
                               ValidateEdits="True"
                               DisableClientCaching="True">
                    <esri:FeatureLayer.MapTip>
                        <Grid>
                            <Rectangle Stroke="Gray"  RadiusX="10" RadiusY="10" Fill="#77FF0000" Margin="0,0,0,5" >
                                <Rectangle.Effect>
                                    <DropShadowEffect/>
                                </Rectangle.Effect>
                            </Rectangle>
                            <Rectangle Fill="#DDFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Margin="10,10,10,15" />
                            <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="30,20,30,30">
                                <TextBlock Text="{Binding [MeterNum]}" HorizontalAlignment="Left" Foreground="Black" />
                                <TextBlock Text="{Binding [Comment]}" HorizontalAlignment="Left" Foreground="Black" />
                                <TextBlock Text="{Binding [Address1]}" HorizontalAlignment="Left" Foreground="Black" />
                                <TextBlock Text="{Binding [Address2]}" HorizontalAlignment="Left" Foreground="Black" />
                              

                            </StackPanel>
                        </Grid>
                    </esri:FeatureLayer.MapTip>
                </esri:FeatureLayer>


Any help would be appreciated. I just need to update the graphic attributes when an item in the list is changed.
0 Kudos
2 Replies
AnttiKajanus1
Regular Contributor II
If I understood correctly what you are trying to do, I think you should just use Graphic's Attributes when changing the values in the edit boxes and bind directly to those. So when user changes the value of the Graphic do the change directly to Attribute[key].

If I missed something let me know and I try to look it a bit more closely.

Edit: Check ArcGIS Runtime SDK for WPF sample : Editing - EditControls - Feature Data Form that might help a bit.
0 Kudos
AnkitaBhatia
New Contributor III
Hi,
I am trying to edit the geometry of a point graphic on graphics layer (using the Editor tool).
What I want toextend this to is to be able to move my other graphics connected to it to move with it.
Eg: I have one system showing a router at locX,LocY and this router is connected to a Building on the locX1,LocY.The connection is displayed through a polyline graphic.
Is there a way to enable the movement of the router end of the polyline when the router is moved using Editor tool??
0 Kudos