Drag and Drop Nested Items

4 posts, 0 answers
  1. Brandon
    Brandon avatar
    10 posts
    Member since:
    May 2012

    Posted 14 May 2012 Link to this post

    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!
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 17 May 2012 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Brandon
    Brandon avatar
    10 posts
    Member since:
    May 2012

    Posted 24 May 2012 Link to this post

    I am using an ObservableCollection in my view model, but it is still behaving as described previously.
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 29 May 2012 Link to this post

    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 >>

Back to Top