This is a migrated thread and some comments may be shown as answers.

Drag&Drop visual only works once

5 Answers 112 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marcel
Top achievements
Rank 1
Iron
Marcel asked on 27 Oct 2016, 04:00 PM

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

5 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 28 Oct 2016, 08:16 AM
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!
0
Marcel
Top achievements
Rank 1
Iron
answered on 28 Oct 2016, 08:47 AM

I'm using version 2016.2.613.45.

Marcel

0
Ivan Ivanov
Telerik team
answered on 01 Nov 2016, 02:30 PM
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!
0
Marcel
Top achievements
Rank 1
Iron
answered on 15 Nov 2016, 01:20 PM
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
0
Ivan Ivanov
Telerik team
answered on 18 Nov 2016, 12:53 PM
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!

 
Tags
GridView
Asked by
Marcel
Top achievements
Rank 1
Iron
Answers by
Ivan Ivanov
Telerik team
Marcel
Top achievements
Rank 1
Iron
Share this question
or