jessica.lott

I need to edit the attributes of a graphic

Discussion created by jessica.lott on Jun 18, 2012
Latest reply on Jun 19, 2013 by ankita_bhatia01
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/MapServer/0"
                               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.

Outcomes