Hi,
I'm using a tooltip to show a small table every time a user mouses over a marker in a particular series on a XamGeographic map.
I've been asked if the tooltip could be pinned in some way, where the user would click on the marker or on the tooltip in order to make it remain visible even when the mouse has been moved away from the marker and tooltip.
Is this possible, and if so what would be the best approach?
Best Regards,
James
Hi James,
There's no way to get the tooltip to stay open with the built-in tooltips. As soon as you mouse away from the marker the tooltip will disappear. What you can do is handle the SeriesMouseEnter and SeriesMouseLeave and display/hide a popup during these events. These events will fire when you hover over a marker and will provide the item associated with the marker.
Rob,
Many thanks for taking the time to respond.
I've tried a few variations on that approach. Currently I am :
1) Using a trigger to set a property on the Item linked to the marker, when the mouse moves over it.
2) Using the property mentioned in step 1 to control the visibility of the popup info box (implemented not as a WPF popup but instead a normal grid, so that it remains anchored to the marker).
The problem with this approach is that if the user scrolls the map so that the info box disappears off screen, and then tries to bring it back onto the screen, the application hands somewhere inside the infragistics source code. I assume what is happening is that the chart is instantiating a finite number of markers, and then assigning the items in the dataset to those makers as they come onto the screen.
So to followup on this approach, I need some way to capture the event that happens when a marker moves off the visible part of the map and is detached from it's corresponding item.
You are correct that the chart creates a finite number of markers and reuses them across the series. WPF gets bogged down if there are a lot of elements in the visual tree so we try to cut down on that by limiting the markers and reusing them as you scroll around. Unfortunately there is no event or way to detect when a marker moves out of view. About the only notification I can think of that would occur at that point is the DataContextChanged event.
This approach seems overly complicated though. If you are worried about MVVM then a Blend Behavior<T> could be used to handle the SeriesMouseEnter and SeriesMouseLeave events on the map. This would keep those handlers out of code behind. You just need to give the behavior a reference to your info box which could be done through XAML and when these events fire, update the info box accordingly from inside the Behavior<T>, maybe by changing it's DataContext.