Here is what I did to get it to work:
First, I created a label in XAML:
<Label Visibility="Hidden" Content="Label" Height="28" HorizontalAlignment="Left" Margin="452,524,0,0" Name="lblMouseOver" VerticalAlignment="Top" />
The margin is arbitrary, but I stuck the label in the middle of the map for now.
Then in the mousemove:
Private Sub WpfMap1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles WpfMap1.MouseMove
Dim worldPointShape As PointShape = ExtentHelper.ToWorldCoordinate(WpfMap1.CurrentExtent, New ScreenPointF(e.GetPosition(WpfMap1).X, e.GetPosition(WpfMap1).Y), WpfMap1.ActualWidth, WpfMap1.ActualHeight)
Dim MyOverlay As LayerOverlay = DirectCast(WpfMap1.Overlays("MyOverlay"), LayerOverlay)
Dim showTooltipTolerance As Double = 0.1
For j = 0 To MyOverlay.Layers.Count - 1
Dim MouseChkBox As New RectangleShape(worldPointShape.X - showTooltipTolerance, _
worldPointShape.Y + showTooltipTolerance, _
worldPointShape.X + showTooltipTolerance, _
worldPointShape.Y - showTooltipTolerance)
Dim bitmapLayer As InMemoryFeatureLayer = MyOverlay.Layers(j)
Dim crossed As Boolean = False
For i As Integer = 0 To bitmapLayer.InternalFeatures.Count - 1
If MouseChkBox.GetDistanceTo(bitmapLayer.InternalFeatures(i), GeographyUnit.DecimalDegree, DistanceUnit.Mile) <= showTooltipTolerance Then crossed = True
Next
If crossed Then
lblMouseOver.Margin = New Thickness(Border2.Margin.Left + e.GetPosition(WpfMap1).X _
, Border2.Margin.Top + e.GetPosition(WpfMap1).Y _
, Border2.Margin.Right - e.GetPosition(WpfMap1).X _
, Border2.Margin.Bottom - e.GetPosition(WpfMap1).Y)
lblMouseOver.Content = "some content"
lblMouseOver.Visibility = Visibility.Visible
Else
lblMouseOver.Visibility = Visibility.Hidden
End If
Next
End Sub
Then I did not need the tooltip class and the performance seem great. I had the map inside a border (border2) with no margin between the map and the border:
<Border BorderBrush="Silver" BorderThickness="1" Height="582" HorizontalAlignment="Center" Margin="328,36,-1,263" Name="Border2" VerticalAlignment="Center" Width="1046">
<my:WpfMap Name="WpfMap1" BorderThickness="1" BorderBrush="#FFBA3939" />
</Border>