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

DragDrop on Label, add to databound tree

1 Answer 22 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 06 Oct 2010, 04:28 PM

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)
      {
         list.Add(tr);
      }
      e.Handled = true;
   }
}

Thanks,
Justin

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 12 Oct 2010, 09:05 AM
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.

Greetings,
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
Tags
TreeView
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or