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
Have a look on following samples. Hope they will help.
- https://developers.arcgis.com/net/sample-code/GraphicsMapTips
- https://developers.arcgis.com/net/sample-code/FeatureLayerMapTips
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
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
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>
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.