I removed GraphicsLayer.MouseEnter and updated the graphic on a button click event my map tip still shows the new value. Please try the attached sample. private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; var graphic = layer.Graphics.FirstOrDefault(g => (int)g.Attributes["ObjectID"] == 24); if (graphic != null) { var oldVal = (int)graphic.Attributes["MyAttribute"]; System.Diagnostics.Debug.WriteLine(oldVal); graphic.Attributes["MyAttribute"] = oldVal + 1; } } If you can tweak this sample and let me know the steps to reproduce the issue you are seeing with Maptip, that would be great.
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; var graphic = layer.Graphics.FirstOrDefault(g => (int)g.Attributes["ObjectID"] == 24); if (graphic != null) { var oldVal = (int)graphic.Attributes["MyAttribute"]; System.Diagnostics.Debug.WriteLine(oldVal); graphic.Attributes["MyAttribute"] = oldVal + 1; } }
Can you share with us your code? The MapTip displays values from graphic attributes, even when these graphics come as a result of a Query. I am using the following SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#GraphicsMapTip with the following code-change.In this sample, I have 2 attributes that I display in my MapTip. One is from the service and the other is a made up attribute that I modify in my code. You can see in the Output window its previous value and in the Maptip its new value. I see that the map tip is updated. If you have some code to share or steps to reproduce, that will be great. <Grid.Resources> <esri:SimpleRenderer x:Key="MyRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleFillSymbol Fill="Red"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer> </Grid.Resources> <esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource MyRenderer}" MouseEnter="GraphicsLayer_MouseEnter"> <esri:GraphicsLayer.MapTip> <StackPanel> <TextBlock Text="{Binding [MyAttribute]}"/> <TextBlock Text="{Binding [HOUSEHOLDS]}"/> </StackPanel> </esri:GraphicsLayer.MapTip> </esri:GraphicsLayer> void StatesGraphicsLayerQueryTask_ExecuteCompleted(object sender, QueryEventArgs e) { GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; foreach (var g in e.FeatureSet.Features) { Random r = new Random(); g.Attributes["MyAttribute"] = r.Next(0, 10); layer.Graphics.Add(g); } } private void GraphicsLayer_MouseEnter(object sender, GraphicMouseEventArgs e) { var oldVal = (int)e.Graphic.Attributes["MyAttribute"]; System.Diagnostics.Debug.WriteLine(oldVal); e.Graphic.Attributes["MyAttribute"] = oldVal + 1; }
<Grid.Resources> <esri:SimpleRenderer x:Key="MyRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleFillSymbol Fill="Red"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer> </Grid.Resources> <esri:GraphicsLayer ID="MyGraphicsLayer" Renderer="{StaticResource MyRenderer}" MouseEnter="GraphicsLayer_MouseEnter"> <esri:GraphicsLayer.MapTip> <StackPanel> <TextBlock Text="{Binding [MyAttribute]}"/> <TextBlock Text="{Binding [HOUSEHOLDS]}"/> </StackPanel> </esri:GraphicsLayer.MapTip> </esri:GraphicsLayer>
void StatesGraphicsLayerQueryTask_ExecuteCompleted(object sender, QueryEventArgs e) { GraphicsLayer layer = this.MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; foreach (var g in e.FeatureSet.Features) { Random r = new Random(); g.Attributes["MyAttribute"] = r.Next(0, 10); layer.Graphics.Add(g); } } private void GraphicsLayer_MouseEnter(object sender, GraphicMouseEventArgs e) { var oldVal = (int)e.Graphic.Attributes["MyAttribute"]; System.Diagnostics.Debug.WriteLine(oldVal); e.Graphic.Attributes["MyAttribute"] = oldVal + 1; }
I wish I could share the code...Anyway, the difference between your sample and mine is that I do not implement GraphicsLayer_MouseEnter event handler. I did a DictionaryConverter and bind maptip value to a graphic attribute (like you did). Am I supposed to implement the mouserEnter event handler in addition to MapTip???
I cannot replicate the issue with the following code:In this sample, I update the number of households and print in the OutputWindow its old value so I can compare the result displayed in my map tip. <esri:FeatureLayer ID="MyStateLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" OutFields="*" MouseEnter="FeatureLayer_MouseEnter"> <esri:FeatureLayer.MapTip> <TextBlock Text="{Binding [HOUSEHOLDS]}"/> </esri:FeatureLayer.MapTip> </esri:FeatureLayer> private void FeatureLayer_MouseEnter(object sender, GraphicMouseEventArgs e) { var oldVal = (int)e.Graphic.Attributes["HOUSEHOLDS"]; System.Diagnostics.Debug.WriteLine(oldVal); e.Graphic.Attributes["HOUSEHOLDS"] = oldVal + 1; }
<esri:FeatureLayer ID="MyStateLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" OutFields="*" MouseEnter="FeatureLayer_MouseEnter"> <esri:FeatureLayer.MapTip> <TextBlock Text="{Binding [HOUSEHOLDS]}"/> </esri:FeatureLayer.MapTip> </esri:FeatureLayer>
private void FeatureLayer_MouseEnter(object sender, GraphicMouseEventArgs e) { var oldVal = (int)e.Graphic.Attributes["HOUSEHOLDS"]; System.Diagnostics.Debug.WriteLine(oldVal); e.Graphic.Attributes["HOUSEHOLDS"] = oldVal + 1; }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.