There is sample on maptip with custom content:
xaml:
<esri:GraphicsLayer>
<esri:GraphicsLayer.MapTip>
<StackPanel Orientation="Horizontal" Background="White">
<TextBlock Text="Feature ID:" />
<TextBlock Text="{Binding}" />
</StackPanel>
</esri:GraphicsLayer.MapTip>
<esri:GraphicsLayer>
My issue is I am adding my graphics layers dynamically in code. How do I achieve the same in my code?
Thanks very much.
<StackPanel Orientation="Horizontal"> <TextBlock Text="ID: " /> <TextBlock Text="{Binding [ObjectID]}" /> </StackPanel>
GraphicsLayer layer = new GraphicsLayer(); layer.MapTip = new MyMapTip(); MyMap.Layers.Add(layer); Graphic graphic = new Graphic() { Geometry = new MapPoint(-140.9, 63.391), Symbol = this.LayoutRoot.Resources["RedMarkerSymbol"] as Symbol }; graphic.Attributes["ObjectID"] = 1234; layer.Graphics.Add(graphic);
You can place any XAML-code in a UserControl and use it as your map tip.
For example, in MyMapTip.xaml
<StackPanel Orientation="Horizontal"> <TextBlock Text="ID: " /> <TextBlock Text="{Binding [ObjectID]}" /> </StackPanel>
You can then have the following code:
GraphicsLayer layer = new GraphicsLayer(); layer.MapTip = new MyMapTip(); MyMap.Layers.Add(layer); Graphic graphic = new Graphic() { Geometry = new MapPoint(-140.9, 63.391), Symbol = this.LayoutRoot.Resources["RedMarkerSymbol"] as Symbol }; graphic.Attributes["ObjectID"] = 1234; layer.Graphics.Add(graphic);
I tried this and it works great, but I cannot use the GraphicsLayer.MapTipHideDelay attribute. Well, actually, I can use it; it just doesn't do what I want.