Quantcast
Channel: Silverlight Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 801

Commented Issue: ListBoxDragDropTarget misses mouse up event occasionally [5930]

$
0
0
In the April 2010 release I've noticed that code that used to work fine in the March 2010 release is now behaving strangely. I have a ListBox that is wrapped in a ListBoxDragDropTarget element. When I click on an item in the list box to select it, sometimes a drag operation is started even though I did not hold down the mouse button. It seems to be fairly repeatable but not consistent. I can't detect a pattern.
 
Inside the ListBoxItem is an object which is listening to mouse events for detecting double click so I will investigate that and report back but I just wanted to post this in case anyone else is noticing the same thing.
Comments: ** Comment from web user: bigfootsoft **

I don't know if anyone is still reading this post, but I'm still gonna post my solution here. I'm currently developing an application where this problem was annoying me a lot. I tried subclassing the DDT using the suggestions posted above but they did not really help.

So I did some research and found out that the "normal" sequence of the drag/drop/mouse-events would be:
```
1. MouseLeftButtonDown
2. OnItemDragStarting
3. OnQueryContinueDrag (multiple times)
4. MouseLeftButtonUp
5. OnQueryContinueDrag
```

In those cases where the item would stick to my cursor, the sequence was slightly different:
```
1. MouseLeftButtonDown
2. OnItemDragStarting
3. MouseLeftButtonUp
4. OnQueryContinueDrag (to infinity and beyond)
```

Notice the missing OnQueryContinueDrag between MouseDown and MouseUp. So you can solve the problem using two flags:
HasQueriedContinueDrag: set to false in MouseDown, set to true in QueryContinueDrag
and
CancelDrag: set to false in MouseDown, set to true in MouseUp if HasQueriedContinueDrag is false

If CancelDrag is set then cancel the dragging operation in OnQueryContinueDrag like andy2001p suggested.

I've attached my complete solution. It is in VB.net but should be pretty self-explanatory, even for C#-ers ;)


Viewing all articles
Browse latest Browse all 801

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>