Can Expression Bland behaviors be used to drag and drop nodes in a WPF TreeView control?

Posted on 2011-04-19
Last Modified: 2013-11-12
Is it possible to attach a behavior to a  WPF TreeView control to enable drag and drop on its nodes? And if there is ... how?
Question by:quentinA
    LVL 11

    Expert Comment

    There is a behavior which let you do dragging (you see the  Visual of the item you drag).
    I suppose that you can put this behavior on the DataTemplate of the treeviewitem, so each item will have it.

    Now you only need to wait for the drop event on your drag scope.
    LVL 11

    Expert Comment

    Hi, I've checked. It seems that MouseDragElementBehavior is not working as expected.
    It doesn't work with buttons for example, and it also causing the TreeViewItem to be not selectable on mouse click.

            xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions" x:Class="WpfTree.MainWindow"
            Title="MainWindow" Height="350" Width="525" AllowDrop="True">
            <HierarchicalDataTemplate DataType="{x:Type local:TreeNode}" ItemsSource="{Binding Nodes}">
                <TextBlock Text="{Binding Text}" Margin="5,0">

            <TreeView ItemsSource="{Binding Nodes}">

    I can suggest you to create your own code that does drag and drop. it is not hard.

    Btw, Telerik has in their demos an example of dragging nodes in a tree.


    Accepted Solution

    I found this example, and it seems to answer my question:

    Author Closing Comment

    shows details of how to use behaviors

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now