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

DragDropManager + DataTemplate

2 Answers 151 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 20 Nov 2012, 02:41 PM
Hi,

our situation is as follows: a RadGridView is shown on the left part of the screen. Right from that there is a RadTabControl with dynamic RadTabItems. Every RadTabItem holds a RadTileView control. The RadTabControl/Items + RadTileView/Items reside in a UserControl (TileViewTabControl2b.xaml in the demo app). Both the RadGridView in the main window and the RadTabControl in the usercontrol use a DataTemplate to render their content (ContentViewModel->RadGridView, WorkspaceViewModel->RadTabControl). Now we want to drag an item from the RadGridView to the RadTileView (inside the RadTabItem). 
Because the RadTabItem and RadTileView do not exist at compile time I pass the handlers to the DragDropManager when the controls are loaded. The handler passed to AddDragOverHandler() is catched as expected but the other handlers like the OnDrop handler are not catchedAny idea why these handlers are not called? 
More general question: what is the preferred way to use the DragDropManager for controls that are created at runtime (by XAML, not in the code behind) like when MVVM is applied?

A demo project can be found here.

Thanks in advance and kind regards,
Vincent

2 Answers, 1 is accepted

Sort by
0
Accepted
Nick
Telerik team
answered on 21 Nov 2012, 12:15 PM
Hi Vincent,

It is possible that some of the controls handle the drag drop events internally. 
Have you tried subscribing to those events with HandledEventsToo set to true?

Looking forward to your response! 

Greetings,
Nikolay Vasilev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Vincent
Top achievements
Rank 1
answered on 21 Nov 2012, 12:27 PM
Thanks Nikolay, your answer was spot on! I was not aware of the existence and meaning of this optional argument.
(edited)
However, now I have another problem, namely that the drop event is handled three times on a row instead of just once. Any idea what could cause this? 
(edited')
It seems that are three controls of the same type created at runtime, each with an eventhandler. That is the downside of runtime created controls; it becomes a bit obscure how they emerge.
Tags
DragAndDrop
Asked by
Vincent
Top achievements
Rank 1
Answers by
Nick
Telerik team
Vincent
Top achievements
Rank 1
Share this question
or