Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2011-04-19
Medium Priority
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
  • 2
  • 2
LVL 11

Expert Comment

ID: 35427401
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

ID: 35427945
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

quentinA earned 0 total points
ID: 35500910
I found this example, and it seems to answer my question:

Author Closing Comment

ID: 35704552
shows details of how to use behaviors

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

810 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