Implement standard tooltip in 10.2.7

2415
5
04-14-2016 03:39 AM
AndrewJones1
New Contributor

How can I implement a standard 'ToolTip' on a dynamically added SimpleLineSymbol? I don't really want the user to have to click on the line, I want the ToolTip to popup when the mouse is over the line.

Andrew

0 Kudos
5 Replies
AnttiKajanus1
Regular Contributor II
0 Kudos
AndrewJones1
New Contributor

The GraphicsMapTips sample is helpful but how do I position the mapTip at the mouse cursor position. Given I have a Polyline the esri:ViewBase.ViewOverlayAnchor="{Binding Geometry}" binding does not work.

Andrew

0 Kudos
AnttiKajanus1
Regular Contributor II

I think that in that case you need to give the mouse location or any other point where you want to put the overlay. Forexample you can create POCO class something like this:

class TooltipModel

MapPoint Anchor <- bind this to the ViewOverlayAnchor

Feature / Graphic TooltipContent <- this would contain the actual item that you are overlaying and then you can bind the attributes to it's Attributes collection and the UI

0 Kudos
AndrewJones1
New Contributor

Because the mouse position is already in pixels I cheated a bit and added the 'Tool Tip' Border as a child of the main Grid. I then changed the margin in the mouse move code.

if (graphic != null)

{

mapTip.DataContext = graphic;

mapTip.Visibility = System.Windows.Visibility.Visible;

mapTip.Margin = new Thickness(screenPoint.X+10, screenPoint.Y, 0, 0);

}

<Grid>

<esri:MapView x:Name="MyMapView">

</esri:MapView>

<Border x:Name="mapTip" Background="#FFFFCC" BorderThickness="0" Padding="4" HorizontalAlignment="Left" VerticalAlignment="Top" Visibility="Collapsed">

     <TextBlock Text="{Binding Attributes[Name], StringFormat='Name: {0}'}" />

</Border>

</Grid>

0 Kudos
AnttiKajanus1
Regular Contributor II

If that works for you it should do the trick. If you use overlays, it will handle map panning etc automatically but if you don't need that kind of behaviour / want to handle it yourself that should work just fine.

0 Kudos