Apply MapTipHideDelay programmatically on map tip

580
1
11-09-2012 11:26 AM
JamilNawaz
New Contributor II
Hi,

I have graphic layer and loading graphics on it using query task. I also have a map tip to display the attribute data in the map tip. Graphic layer is being created programmatically and also creating map tip programmatically. I have written the following code on the query task complete event.
var gl = (GraphicsLayer)MainMap.Layers["MyGraphicLayer"];
var features = args.FeatureSet.Features;
gl.Graphics.Clear();

foreach (var graphic in features)
{
 graphic.Symbol = (Symbol)Application.Current.Resources["MySymbol"];

 graphic.MapTip = new MyMapTip(graphic);
 GraphicsLayer.SetMapTipHideDelay(graphic.MapTip, new TimeSpan(0, 0, 0, 0, 500));
 gl.Graphics.Add(graphic);
}

This is the constructor of my MyMapTip user control
public MyMapTip(Graphic graphic)
{
 InitializeComponent();
 DataContext = graphic.Attributes;
}

This is the xaml of the user control ,where I define the binding and display an attribute value.
<StackPanel Orientation="Horizontal">
 <TextBlock VerticalAlignment="Center"
            FontSize="10"
            FontWeight="Bold"
            Foreground="Black"
            Text="Nombre: " />
 <TextBlock HorizontalAlignment="Left"
            VerticalAlignment="Center"
            FontSize="10"
            Foreground="Black"
            Text="{Binding [NOMBRE]}" />
</StackPanel>

Now when I mouse over the graphic, map tip appears but i never disappear after 0.5 sec. It stays there unless I pan/zoom or mouse over to other graphics on the map.

Any one can suggest, what I am making mistake?
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
I don't see anything wrong in your code.
Note that the hide delay is calculated from the moment you leave the graphic. As long as you hover the graphic, the maptip is visible whatever the maptipdelay. Can this explain your behavior?

Sidenote: to avoid the creation of one maptip by graphics, you could create only one and affect it to the graphics layer.
0 Kudos