3
votes

I am opening a separate question about the reason for this issue so that my other question can be about possible workarounds.

So I have drag and drop enabled for a listview but I noted that the UIelement.IsMouseOver doesn't work during a drag and drop operation. In particular during a drag and drop operation, if IsMouseOver is tested while the mouse is over an element it will return false when it should return true. The same function works perfectly when tested before the drag and drop operation.

I have also read that there is an issue online.

Source: "This is because WPF blocks all mouse actions when we doing drag drop action. You can use EventTrigger with an animation to do this."

http://social.msdn.microsoft.com/Forums/vstudio/en-US/9a73b1b0-ec76-4b2c-8da6-91c71e3c406f/wpf-mouse-click-event-on-scrollbar-issue?forum=wpf

However, I would like to know what exactly "blocking all mouse action" entails. It seems like someone ought to fix IsMouseOver to operate with drag and drop

1

1 Answers

2
votes

I wouldnt see this as an issue because it is how things are in wpf by design. Mouse is not blocking anything mouse is being captured when doing drag and drop. In order to have the IsMouseOver property set to True the control or visual in wpf needs to capture the mouse pointer. However when you start dragging something from a source control to a destination control, the destination control is not capturing the mouse once over it because it is the source control on which the mouse was and still is being pressed. Source control needs to capture the mouse and hold it caputured until the desired operation is done. For example by capturing mouse by source control the source control may keep track where mouse is and check if the visual which is mouse pointer currently standing on allows drop behavior at all. If so the mouse cursor will get changed.

There are many solution for this. You could use EventTrigger in your style and listen to drag event instead of having simple Trigger listening to IsMouseOver. Another solution would be to have own property. Since IsMouseOver only has a getter you could create your own attached property that allows itself to be set when mouse over or drag and drop is being performed. You could use your own property instead IsMouseOver.