ListBox, RichTextBox and TreeView - drag and drop problem

3 posts, 0 answers
  1. Dmitry
    Dmitry avatar
    20 posts
    Member since:
    Apr 2011

    Posted 29 Jun 2014 Link to this post

    Hello!

    I have a view with a RadListBox consisting of RadRichTextBoxes on the left, and RadTreeView on the right.
    Previously I just needed DragDrop behavior to enable user reorder items inside ListBox view, but now I am implementing scenario when user can drag an item from TreeView into one of the RadRichTextBoxes (this will insert some text at the caret position, but that does not matter).
    I made this scenario work, but discovered that attempt to reorder items in ListBox now does not work correctly - if a dragged list item is dropped on a visual line before or after some other text item - it just disappears from the view. During investigation I discovered that all is ok unless I subscribe to any RadRichTextBox DropPreview event (to process tree item drop into RichTextBox). After this subscription is made DrapDrop behavior method Drop is never called, thus dragged list item is removed from ListBox ItemsSource collection and never added back to it with new index.

    Thus my question is - how can I fix this problem and get both DragDrop scenarios work correctly?
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 01 Jul 2014 Link to this post

    Hi Dmitry,

    The issue in this particular scenario is probably caused by the mentioned PreviewDrop event handler of the RichTextBox. If you have handled the event (by setting the e.Handled = true) the DragDropCompleted event of the ListBox won't be fired and the item won't be added again while reordering. Please try to set the e.Handled to false and let me know if this helps. If it doesn't I'll ask you to share a sample project so we can investigate the scenario on our side.

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 02 Jul 2014 Link to this post

    Hi Dmitry,

    I'm sorry in my previous post I meant that the Drop event of the ListBox won't be fired not the DragDropCompleted event.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top