Cross Hair cursor is not displaying when MapTool is called from SDK code.

885
1
Jump to solution
06-25-2021 08:08 AM
TapasChakrabarty
New Contributor III

I have implemented MapTool functionality where I am calling the tool using ICommand.Execute(). Everything is working fine. On mouse down, I am able to fetch the MapPoints X/Y. But when I hoover on the Map the cross-hair cursor is not displaying instead the Hand cursor is displaying. 

 Any idea how to resolve the issue.

Below are the codes:

protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
{
//On mouse down check if the mouse button pressed is the left mouse button. If it is handle the event.
if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
e.Handled = true;
}

/// <summary>
/// Called when the OnToolMouseDown event is handled. Allows the opportunity to perform asynchronous operations corresponding to the event.
/// </summary>
protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
{
//Get the map coordinates from the clicked point and set the property on the ViewModel.
return QueuedTask.Run(() =>
{
var mapPoint = ActiveMapView.ClientToMap(e.ClientPoint);
sb.Append(string.Format("{0}", mapPoint.X));
sb.Append(string.Format("#{0}", mapPoint.Y));
if (mapPoint.HasZ)
{
sb.Append(string.Format("#{0}", mapPoint.Z));
}
Application.Current.Properties["Coordinate"] = sb.ToString();
sb.Clear();
});
}

0 Kudos
1 Solution

Accepted Solutions
KrisCulin
Occasional Contributor

Try overriding OnToolActivateAsync and set the Cursor property like so:

Cursor = Cursors.Cross;    //Cursors is in the System.Windows.Input namespace.

That should work.  

Kris

View solution in original post

1 Reply
KrisCulin
Occasional Contributor

Try overriding OnToolActivateAsync and set the Cursor property like so:

Cursor = Cursors.Cross;    //Cursors is in the System.Windows.Input namespace.

That should work.  

Kris