treeviewitem not expanding when new item dropped on

2 posts, 0 answers
  1. Brian
    Brian avatar
    20 posts
    Member since:
    Jan 2011

    Posted 28 Feb 2011 Link to this post

    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;
                       appList.ItemsSource = freeApps;
                       stationTree.ItemsSource = stations;

    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! 
  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 01 Mar 2011 Link to this post

    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!
Back to Top