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

treeviewitem not expanding when new item dropped on

1 Answer 51 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 01 Mar 2011, 05:48 AM
I have a list box that drops an item onto a treeView.   The TreeView is bound to a List<> and has a two level template.  The Item is dropped on the top level items and need the item to expand when the new item is dropped on it.

private void OnDropInfo(object sender, DragDropEventArgs e)
       {
             
               if (e.Options.Status == DragStatus.DropComplete)
               {
                     
                   ListBoxItem item = e.Options.Source as ListBoxItem;
                   DeviceApp payload = item.Content as DeviceApp;
                   freeApps.Remove(payload);
                   appList.UnselectAll();
                   appList.ItemsSource = freeApps;
                   stationTree.ItemsSource = stations;
                   appList.Items.Refresh();
                   stationTree.Items.Refresh();
                     
               }
                
             
       }


The listBox is the source and i have added some clunky Refresh() to get both ItemsSources to update and show the changes.  I know i am doing this wrong, but the tree branch still does not expand on drop.

Any help would be great! 
Thanks,
Brian

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 01 Mar 2011, 10:25 AM
Hello Brian,

The RadTreeView has a built-in drag/drop logic that can be used out-of-the-box in order to implement your scenario. You can examine this demo demonstrating how to drag items from ListBox to the RadTreeView and vice verca (the demo is for Silverlight, however you can implement it in WPF as well). You can also have a look at this help article for more info.

Also, please keep in mind that in databound scenarios, when you want the changes applied to the ItemsSource collection of the RadTreeView to be reflected by the control, then you need to bind it to a collection that implements the INotifyCollectionChanged interface, for example an ObservableCollection.

I hope that info helps.

All the best,
Tina Stancheva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeView
Asked by
Brian
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or