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

Drag and Drop Nested Items

3 Answers 93 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 14 May 2012, 05:04 PM
Hello all,

I am trying to create a hierarchical tree view (about 3 levels), where the user can drag/drop to re-order, or move items only within the same level, but cannot move items between levels.  Basically I want to maintain a strict hierarchy of items (C's belong only to B's and B's belong only to A's).

I have tried using a hierarchical data template for my view model (which implements INotifyPropertyChanged) but can only reorder the top level nodes and cannot reorder the child nodes.


Thanks for any help!

3 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 17 May 2012, 07:23 AM
Hi Brandon,

In order to reorder RadTreeViewItems in databinding scenarios, you have to make sure the root ViewModel Collection and the Child ViewModel collections are ObservableCollection. Usually the ViewModels structure you have to use is:
MainViewModel
{
  public ObservableCollection<DataItem> RootCollection;
}
 
DataItem
{
 public string Header
 public ObservableCollection<DataItem> Children;
}
Please let us know if this helped you or not.

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Brandon
Top achievements
Rank 1
answered on 25 May 2012, 01:00 AM
I am using an ObservableCollection in my view model, but it is still behaving as described previously.
0
Petar Mladenov
Telerik team
answered on 29 May 2012, 07:11 AM
Hi Brandon,

 I think this example could help you. You can examine it's code which shows how to prevent certain drag/drop operation when a particular condition is true/false. Same technique could be used in WPF.

Kind regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
Brandon
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Brandon
Top achievements
Rank 1
Share this question
or