• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 789
  • Last Modified:

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

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?
  • 2
  • 2
1 Solution
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.
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.

quentinAAuthor Commented:
I found this example, and it seems to answer my question:
quentinAAuthor Commented:
shows details of how to use behaviors
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now