DragDropManager + DataTemplate

3 posts, 1 answers
  1. Vincent
    Vincent avatar
    8 posts
    Member since:
    Mar 2012

    Posted 20 Nov 2012 Link to this post


    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,
  2. Answer
    Nick avatar
    593 posts

    Posted 21 Nov 2012 Link to this post

    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! 

    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Vincent
    Vincent avatar
    8 posts
    Member since:
    Mar 2012

    Posted 21 Nov 2012 Link to this post

    Thanks Nikolay, your answer was spot on! I was not aware of the existence and meaning of this optional argument.
    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? 
    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.
Back to Top