locked
Drag&Drop behavior not work in correct way in SIlverlight 4 RRS feed

  • Question

  • Hi Guys, I just recently upgrade to Silverlight 4. And found the drag&drop behavior has broken.

    This issue can even be reproduced in SL4 toolkit samples: http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html

    When I trying to just select an item (eg. a text item in ListBox), some times the drag event fires, event I had released left mouse button, drag operation still continue.

    After few times trying, I found this is easy to reproduce if I trying to quickly select items in dragdrop container.

    This issue is not exist in previous Silverlight 3.
    Can some one offer any help ???

    Tuesday, May 4, 2010 3:45 AM

All replies

  • Any one experience same problem?

    Wednesday, May 5, 2010 8:17 PM
  • Hi Andy, I have got the same problem just right after my project has been updated to Silverlight 4 and the latest Toolkit version. The bug is very noisy. The drag thumbnail appears without any reason if an item in ListBox or DataGrid is just clicked without intention to drag it. I thought that is a problem of my project, maybe somewhere I have put a hook etc. But I have created the demo example with two ListBoxes and it reproduces every time. I guess that is a huge issue of the Toolkit, and I'm very interesting if there are any plans to fix that or do I need to investigate their source-code and find the problem by myself =(... Regards.
    Thursday, June 3, 2010 9:24 AM
  •  I am unable to reproduce this at all. The only way I can get a near repro is if I am clicking and moving the mouse very fast. If you start to move the mouse before you let go of the left mouse button at all there is chance for drag, but this is normal activity. Perhaps there was a change in sensitivity or I have tested this type of functionality too many times and am unable to get the undesired outcome. Interesting why this is happening...

    Does this occur even if you click without moving and then release the mouse button? Is your mouse sensitivity high? Just curious what else may be causing this. Is there a side by side SL3/SL4 comparison to display a major difference?

     

    Thanks

    Thursday, June 3, 2010 9:38 AM
  • Hi,

     So, due to the very important level of the issue to my problem I would like to describe the steps to reproduce as much detailed as possible.

     First of all I have recoded a small video-cast with demonstrating how issue looks like on my PC, here is a link to download (2.2 MB): http://rapidshare.com/files/394860286/2010-06-03_1854.swf.html.

    So, I was able to reproduce the issue on the official samples of April 2010 Toolkit, but it doesn't reproduce all times :-(. For example it doesn't fail on Mac OS X, but my project with drag-n-drop definitly fails on Mac.

    So main scenarion how to reproduce is to open a sample with ListBox wich is inside ListBoxDragDropTarget with AllowDrop=true. When you have to start make clicks (mouse down and mouse up on the same item) on first two items one by one. Depending on the time gaps between clicks and mouse out from an item, the drag thumbnail appears.

    By design it should appear only if I make mouse down + mouse out. But it also appears when I do mouse down, mouse up and when mouse out.

    Thursday, June 3, 2010 12:14 PM
  • Hi all, I've got the same issue and just wanted to add some insights: the "undesirable" behavior may be caused by WriteableBitmap which is used to render dragged element. From my experience, it has a huge performance overhead especially in case of complex visual trees. The drag-drop events logic is just discovering the problem, but I think the key point is the complexity of visual tree.

    By the way, are there any plans to move drag-drop framework from experimental quality band? I'm looking at April 2010 source code.

    Thursday, June 3, 2010 12:50 PM
  • Hi,

     I'm also looking at the Toolkit's source code and trying to understand the nature of the issue. Though the RX-way development isn't very easy to understand to a beginner. I suppose that the problem is located somewhere in DragDropTarget, which produce the call of OnItemDragStarting(ItemDragEventArgs eventArgs) for ListBoxDragDropTarget.

    There is a code:

     

            private IObservable<IEvent<ItemDragEventArgs>> GetItemDragStarting()
            {
                return
                    from mouseLeftButtonDown in this.GetMouseLeftButtonDownAlways().ObserveOnDispatcher()
                    let originalSource = (UIElement) mouseLeftButtonDown.EventArgs.OriginalSource
                    let offset = GetOffset(mouseLeftButtonDown.EventArgs, originalSource)
                    from dragStarted in
                        Application.Current.RootVisual
                        .GetMouseMove()
                        .SkipWhile(moveEvent =>
                                       {
                                           Point point = GetOffset(moveEvent.EventArgs, originalSource);
                                           return Math.Abs(point.X - offset.X) <
                                                  SW.SystemParameters.MinimumHorizontalDragDistance &&
                                                  Math.Abs(point.Y - offset.Y) <
                                                  SW.SystemParameters.MinimumVerticalDragDistance;
                                       })
                        .Take(1)
                        .TakeUntil(Application.Current.RootVisual.GetMouseLeftButtonUpOnSelfAndSiblingsAlways())
                    
                        ...
            }
     

    As I have understood the drag start event should be raised if mouse moves out of the offset 4x4 px until the mouse up event will be performed. It looks similar top the bug which we have got.

     I have check the problem in my project one more time, and it (showing of drag thumbnail) reproduces (sometimes) when I just click (mouse down and mouse up) on the item, and move mouse for 5 px staying on the item.

    So, maybe the problem is that there can be situations when dragStarted is performed in between the time when ".TakeUntil(Application.Current.RootVisual.GetMouseLeftButtonUpOnSelfAndSiblingsAlways())" condition is evaluated and the offset calculation is executed. Which follows to the case when dragStart is dispatched after the mouse button up is raised, which must be definitly prohibited.

    If somebody get the deeper knowledge, please help.

    Regards.

    Thursday, June 3, 2010 2:41 PM
  •  Hi,

     

    I am experiencing the same issue. Has anyone found a solution?

     I have been also trying to implement a logic to stop this annoying bug, but I can not find a method to cancel the drag&drop operation from code. Do you know how to do it?

    Monday, June 28, 2010 4:04 AM
  • Hi,

    You should try to use the solution from here: http://silverlight.codeplex.com/workitem/5930. There is an attached file FixedListBoxDragDropTarget.txt with the patched DragDropTarget.

    It works for me because it mutes wrong drag starting basing on manual checking of mouse up event. So, I have patched all my code to keep the project in a good shape, but still looking forward for the fix from Toolkit team.

    Regards.
    Monday, June 28, 2010 4:21 AM
  • Is there an open bug on this?  I just logged on to search for some type of drag drop begin delay setting and found this thread.  I'm seeing the problem with DataGridDragDropTarget and it's creating a pretty bad impression with my users as they work with my app.  If a fix is in the works, I won't bother with downloading the workaround code above.

    Thanks,

    Chris

    Wednesday, June 30, 2010 3:04 PM
  • Hi Chris,

    The workaround code above doesn't have any relation to the problem with poor speed of creation of drag thumbnail. To resolve your issue, you should inherit the DataGridDragDropTarget and override the code of creation thumbnail using Bitmap to something more faster.

    Regards.
    Wednesday, June 30, 2010 4:52 PM
  • Thanks for the reply.  The problem I'm having is what is desribed in this thread though.  I went ahead and used the workaround for my DataGridDragDropTargets and it's much more pleasant to use now.

     

    -Chris

    Thursday, July 1, 2010 11:21 AM
  • This problem is very annoying, and I ask for the SL Toolkit team to please take it seriously. We can't use the previously mentioned Fixed DragDropTarget. Regardless of that, that code only hides the problem instead of fixing it.

    Has anyone found a solution to this yet? Thanks.

    Associated issues:

    1. http://silverlight.codeplex.com/workitem/5930
    2. http://silverlight.codeplex.com/workitem/6044
    3. http://silverlight.codeplex.com/workitem/4795
    Friday, July 30, 2010 12:41 PM
  • Not really, my company is still suffering)) But there are a few things that help me suffer better:

    1. To fix FixedListBoxDragDropTarget - in the original implementation mouse tracking is done only in bounds of drag-drop target, but there are a few cases which require mouse tracking on visual root. So i just used root visaul as event source instead of drag-drop target itself.
    2. To rewrite ListBoxDragDropTarget - if you need a better handle on drag selection or drag thumbnail. Its fairly simple task.
    3. To rape Toolkit's source code - in this case you can do everything with drag-drop targets but it requires time and understanding. We didn't go this way so far.

    So seems that without help from MS the best solution will be case specific and maybe refusing drag-drop framework is a better way to go.

    Friday, July 30, 2010 1:17 PM
  • Has anyone found a solution to this yet?

    I've the same issue in a TreeViewDragDropTarget 

    and still there is a bonus :)

    If quickly to click elements in a treeview, they will disappear after a while. It's very annoynig. 

    Tuesday, August 24, 2010 5:05 PM
  • I don't have a solution, but I had the problem of dragging when it shouldn't.  I just gave up on drag and drop.  Sad really.

    Tuesday, August 24, 2010 5:12 PM
  • Will this at least be fixed in the next SL toolkit version?

    Friday, August 27, 2010 3:17 AM
  • Having the same issues with the TreeViewDragDropTarget

    Any news on a fix? (or a new toolkit release? It has been ages!)

     

    Friday, October 1, 2010 10:02 AM
  • Add me to the list of people with the DragDrop-Issue (for the TreeView in my case). The fix described here: http://silverlight.codeplex.com/workitem/5930 (the FixedListBoxDragDropTarget.txt adapted for the TreeView) seemed to have solved this issue for me. (Haven't done heavy testing yet)

    Wednesday, January 26, 2011 11:47 AM
  • The fix didn't do it for me so I have suggested another work around.

    See http://silverlight.codeplex.com/workitem/5930

    Any feedback appreciated.

    Sunday, March 6, 2011 10:12 PM
  • This has been broken for over a year now.

    At this point, should I just assume that no one has any intention of fixing it, and that if I want drag/drop in my silverlight app I have to implement it myself?  Clearly the tookit implementation is broken.

    Tuesday, May 31, 2011 2:50 AM
  • Still, no fix? Really?

    Tuesday, September 6, 2011 9:03 PM