Drag&Drop visual only works once

6 posts, 0 answers
  1. Marcel
    Marcel avatar
    21 posts
    Member since:
    Jul 2011

    Posted 27 Oct Link to this post

    Hi there,

    just a quick question: I'm trying to implement dragging items from one RadGridView to another. I basically sticked to the example from the Telerik docs (http://docs.telerik.com/devtools/wpf/controls/dragdropmanager/how-to/howto-draganddrop-within-radgridview). And it works! Only once, though. First time I drag an item, I can see the visual as expected and I can drop it on the other grid. When I try to drag the next item, no visual appears. Same thing with the following tries. If I restart the view, again, only the first drag operation shows the visual. Interestingly, the drag/drop operation works all the time. Only the visual vanishes after showing up once...

    Seems to me like something is not properly cleaned up and kind of re-initialized in some wrong way the second time.

    Does someone have an idea?

    Marcel

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 28 Oct Link to this post

    Hi,

    Could you please confirm which version of Telerik UI for WPF you are currently using? Is it 2016.3 1024?

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Marcel
    Marcel avatar
    21 posts
    Member since:
    Jul 2011

    Posted 28 Oct in reply to Ivan Ivanov Link to this post

    I'm using version 2016.2.613.45.

    Marcel

  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 01 Nov Link to this post

    Hi,

    I prepared a sample project basing it on the given code sample and it seems that it is working fine (the version that you mentioned is used). I am attachig it to the thread for your reference. Can you please confirm whether you are follwoing the sample correctly, or you are making some modifications in the logic? SImilar behavior may occur if teh DragVisual content is set directly to a UI element, instead of using a DataTemplate. Thus the element might be shown, as it already has a visual parent. 
    Please have a look at the project and tell me whether you see any distinct differences. You can also open a support ticket and send us the project that you have, so that I can debug it on our side.

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  6. Marcel
    Marcel avatar
    21 posts
    Member since:
    Jul 2011

    Posted 15 Nov in reply to Ivan Ivanov Link to this post

    Hi Ivan,

    first of all thank you for your answer and example. Had to focus on different topics meanwhile but returned to the drag/drop stuff today. Your feedback helped me getting on the right way to finally find the reason for the strange behavior. Maybe, I should have mentioned that I use the Telerik controls in a very special context here: legacy winforms MDI application > MDI child form > elementhost > WPF control > RadGridViews with d&d support. It turned out, the described behavior (DragVisual showing up only once per view lifecycle) was caused by the System.Windows.Application instance which I created in the forms application to have a dispatcher ready for the WPF controls. After I removed this and switched from System.Windows.Application.Current.Dispatcher to System.Windows.Threading.Dispatcher.CurrentDispatcher, the problem with the DragVisual went away and also this Dispatcher seems to run much more stable in the described setup. 

    I still don't understand completely what was going on here, but also I'm not too curious on finding it out since hosting WPF controls in winforms apps isn't something I look forward to do too often in the future ;)

    Regards,
    Marcel
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 18 Nov Link to this post

    Hello,

    I am glad to hear that you managed to resolve it. There are some specific pitfalls when working with Drag and Drop, when controls are hosted in a WinForms project. A Drag operation would open and then close a drag visual, which is actually a window that is associated with the WPF Application instance. Depending on its ShutdownMode, the Application instance may be closed thus resulting in killing the associated thread. You can either stick to the workaround that you found, or you can try setting the property to OnExplicitShutdown, which would allow the Application instance to stay alive.

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!

     
Back to Top
UI for WPF is Visual Studio 2017 Ready