Domanda

I'm trying to work with Bing Maps in WPF, but everything is confusing as searching online leads me to false hope. I'll search for something, but get the AJAX version instead of the WPF version. If anyone can point me to proper documentation or help with this issue then I will be forever in their debt.

I have a map in my WPF app that I would like to track when a user is scrolling. I tried tying the map to the DragEnter event, but that didn't do anything. My question is if there is an event that I can use to check if the user is panning or zooming through the map?

Thanks in advance.

È stato utile?

Soluzione

The event ViewChangeOnFrame seems to do what you want.
See Handing Map Events

<m:Map ViewChangeOnFrame="MyMap_ViewChangeOnFrame" ...>

From MSDN

Assuming you have a TextBlock element named CurrentPosition defined in the XAML design code, you can track the current position of a map view while it is animating between locations. This code tracks the position, in latitude and longitude, of the northwest and southeast corners of the bounded map view.

void MyMap_ViewChangeOnFrame(object sender, MapEventArgs e)
{
    //Gets the map that raised this event
    Map map = (Map) sender;
    //Gets the bounded rectangle for the current frame
    LocationRect bounds = map.BoundingRectangle;
    //Update the current latitude and longitude
    CurrentPosition.Text += String.Format("Northwest: {0:F5}, Southeast: {1:F5} (Current)",
                bounds.Northwest, bounds.Southeast);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top