Copy from one tree to another but move when dragged in own tree

3 posts, 1 answers
  1. Anders
    Anders avatar
    12 posts
    Member since:
    Apr 2011

    Posted 03 May 2011 Link to this post

    Hi, I got two treeview'sv called T1 and T2 from now, and I need them to behave like illustrated in this image.

    Copy N Move

    1. If the dragged item is being dragged in the same treeview just move it.
    2. If the dragged item is being dragged from T1 to T2 Copy it.
    3. It the dragged item is being dragged from T2 to T2 disallow it.
  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 06 May 2011 Link to this post

    Hi Anders,

    In order to implement this scenario you will need to handle the first TreeView control's PreviewDragEnded() event in case when the TargetDropItem is in the second TreeView control. This will implement the copy drag from tree1 to tree2.

    In order to deny drag/drop operations from tree2 to tree1, you need to handle the OnDropQuery() event for the first TreeView. Then if the dragged item comes from the second tree, you will need to return a QueryResult false, which will indicate that the drop operation is invalid and will not allow it to happen.

    I attached a sample project to get you started. I hope it helps.

    Best wishes,
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Anders
    Anders avatar
    12 posts
    Member since:
    Apr 2011

    Posted 10 May 2011 Link to this post

    Works just like i needed it to.

    Thanks for a great support :-D
Back to Top