I am trying to get a silverlight popup to display near the mouse when I hover over a map element.
Is there a way of getting the mouse position from the elements symbol position?
this is not exposed as a feature of the map; however, you can use the RenderTransform of the Map Viewport's RootCanvas to translate the coordinate.
private void XamWebMap_ElementHover(object sender, MapElementHoverEventArgs e) { XamWebMap theMap = (XamWebMap)sender; Point pos = e.Element.ActualSymbolOrigin; pos = theMap.Viewport.RootCanvas.RenderTransform.Transform(pos); Popup pop = new Popup(); pop.Child = new TextBlock() { Text = "hello" }; pop.HorizontalOffset = pos.X; pop.VerticalOffset = pos.Y; pop.IsOpen = true; }
alternatively, you could just use the MouseMove event, and avoid referencing any MapElement.
If use MouseMove event, will it slow down the silverlight page and have bad performance.
David Negley"] this is not exposed as a feature of the map; however, you can use the RenderTransform of the Map Viewport's RootCanvas to translate the coordinate. private void XamWebMap_ElementHover(object sender, MapElementHoverEventArgs e) { XamWebMap theMap = (XamWebMap)sender; Point pos = e.Element.ActualSymbolOrigin; pos = theMap.Viewport.RootCanvas.RenderTransform.Transform(pos); Popup pop = new Popup(); pop.Child = new TextBlock() { Text = "hello" }; pop.HorizontalOffset = pos.X; pop.VerticalOffset = pos.Y; pop.IsOpen = true; } alternatively, you could just use the MouseMove event, and avoid referencing any MapElement.
These codes populate the position of that element, it's not exactly the position of mouse.
How could I get exactly the position of mouse?
This is nice code. However, what reference do I use to get to the Popup class?
I am trying to do the same thing as wmlanza2, show a popup while hovering over a map element and display some of the data from SQL and have not been able to find any documentation or examples. Can someone point me in the right direction? Thanks.