Hi,
When world spatial data is loaded into MapLayer, each country will be highlighted when mouse hovers.
I want to change that behavior. Instead of highlighting each country, I want to highlight a group of countries when mouse hovers.
How could i achieve it?
Thanks,
Regards,
NNT
Hi Ivan,
Great. That's exactly what i am looking for.
Thanks.
Hi nyinyithann,
you can attach to XamMap's ElementHover and ElementUnhover and control manually group of contries that should be highlighted. Try the following code snippet:
xamMap.ElementHoverAction = ElementHoverAction.None;xamMap.ElementHover += xamMap_ElementHover;xamMap.ElementUnhover += xamMap_ElementUnhover;
private List<MapElement> _highlightedElements = new List<MapElement>(3);
void xamMap_ElementUnhover(object sender, MapElementHoverEventArgs e){ foreach (var element in _highlightedElements) { element.Fill = null; }
_highlightedElements.Clear();}
private void xamMap_ElementHover(object sender, MapElementHoverEventArgs e){ if (e.Element.Caption == "United States") { _highlightedElements.Add(e.Element); _highlightedElements.Add(xamMap.Layers[0].Elements["Mexico"].Single()); _highlightedElements.Add(xamMap.Layers[0].Elements["Canada"].Single());
foreach (var element in _highlightedElements) { element.Fill = new SolidColorBrush(Colors.Orange); } } }
Please let me know if this works for you.
Ivan Kotev