Ask Your Question
3

How can the mouse or gesture position be obtained during Drag and Drop events in .Net MAUI or in the drop events, how can the final position of the mouse be retrieved?

asked 2022-10-11 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-03-14 18:00:00 +0000

qstack gravatar image

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
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-10-11 11:00:00 +0000

Seen: 9 times

Last updated: Mar 14 '22