DragDrop on Label, add to databound tree

2 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    176 posts
    Member since:
    Dec 2009

    Posted 06 Oct 2010 Link to this post

    I have 2 databound TreeViews and a Label.  The requirement is to drag an item from the Tree1 onto the label, and this would add the item to Tree2. (without removing the item from Tree1)   Both trees are bound to objects of the same type.

    I have added a Handler for the DropInfoEvent on the Label, and add the payload to Tree2.  The code in the Handler executes correctly and does not throw an error.  The ItemsSource of Tree2 shows that it has the added Item(s) if subsequent events, but the Tree2 never updates. (always shows original list)

    void lblContextName_OnDropInfo(object sender, DragDropEventArgs e)
       if (e.Options.Status == DragStatus.DropComplete)
          System.Collections.IList list = 
             (tree2.ItemsSource as System.Collections.IList);
          foreach (TempResource tr in (System.Collections.IList)e.Options.Payload)
          e.Handled = true;

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 12 Oct 2010 Link to this post

    Hi Justin Lee,
    I am not entirely sure what might be causing the issue from the information you gave us. However, I was wondering what is the type of the ItemsSource collection of the RadTreeViews. If this collection doesn't implement the INotifyCollectionChanged interface, the RadTreeView won't be aware whether any changes are applied to that collection thus causing the described behavior.

    I prepared a sample project illustrating a possible approach towards your scenario, and I set an ObservableCollection as an ItemsSource of both RadTreeVies. Please take a look at it and let me know if it works for you.

    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top