Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

In .NET MAUI, to obtain the mouse or gesture position during Drag and Drop events, you can use the DragEventArgs parameter of the DragOver and DragEnter event handlers. The DragEventArgs parameter contains a GetPosition method that you can use to get the position of the mouse or gesture relative to the control that is handling the event.

For example:

private void OnDragOver(object sender, DragEventArgs e)
{
    Point position = e.GetPosition((IView)sender);
    // use the position to update the UI or perform other logic
}

Similarly, to retrieve the final position of the mouse during a drop event, you can use the DropEventArgs parameter of the Drop event handler. The DropEventArgs parameter also has a GetPosition method that you can use to get the final position of the mouse or gesture relative to the control that is handling the event.

For example:

private void OnDrop(object sender, DropEventArgs e)
{
    Point position = e.GetPosition((IView)sender);
    // use the position to update the UI or perform other logic
}