[]
In this topic, you will add code to your project that will return the geographical coordinates of the current mouse position. These geographical coordinates will then be written as a string to the Text property of a TextBox control.
To get the geographical coordinates of the current mouse position, complete the following steps:
Add a StackPanel, a TextBox control, and a Maps control to your project.
Set the StackPanel's properties as follows:
Set the TextBox control's Name property to "ShowCoordinates".
Set the C1Maps control's properties as follows:
Select the C1Maps control and then, in the Properties panel, click the Events button .
In the MouseMove text box, enter "MouseMoveCoordinates" and press ENTER to add the MouseMoveCoordinates event handler to your project.
Replace the code comment with the following code:
C1Maps map = sender as C1Maps;
Point p = map.ScreenToGeographic(e.GetPosition(map));
ShowCoordinates.Text = string.Format("{0:f6},{1:f6}", p.X, p.Y);
Press F5 to run the project. Once the project is loaded, run your cursor over the map and observe that geographical coordinates appear in the text box.