TreeListView drag and drop showing adorner for 'On', but passing 'After'

Grids for WPF Forum

Posted 7 years ago by Nick Waanders
Version: 17.1.0652
Platform: .NET 4.6
Environment: Windows 10 (64-bit)


I am trying to get drag & drop working for my TreeListView, and I noticed a possible bug in the adorner for the nodes in the tree.

For some dragged items, I want to disallow dropping 'On' targets, just 'Before' and 'After', so in the OnDragOver and OnDrop I check to see if the incoming 'dropArea' is set to 'TreeItemDropArea.On', and if it is, I return TreeITemDropArea.None. This works well logically (the items get dropped in the proper space in the OnDrop), but I noticed that the adorner for the targetItem still shows 'On' for all items except the last one in the list of children. 

To reproduce this problem, in the TreeListBoxDragDrop example, in CustomTreeListBoxItemAdapter.cs on line 81 change:

if ((targetItem != null) && (dropArea != TreeItemDropArea.None) && (e.Data.GetDataPresent(TreeListBox.ItemDataFormat))) {


if ((targetItem != null) && (dropArea != TreeItemDropArea.None) && (dropArea != TreeItemDropArea.On) && (e.Data.GetDataPresent(TreeListBox.ItemDataFormat))) {

Then, drag the 'Cherry' item onto the 'Raspberry' item. I'd expect that only the After or Before adorners would show up, but when moving the mouse around a bit, you can get the 'On' adorner to show, when the 'After' adorner should be showing instead. 

When dragging the 'Cherry' item onto the last item in the berries list 'Strawberry', it does work correctly. 



Comments (1)

Posted 7 years ago by Nick Waanders

Actually, nevermind!

I missed that there is code in the sample that Coerces the returned value, which explains everything.

(And of course I noticed this about 5 seconds after I pressed send on the message above...)

The latest build of this product (v24.1.2) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.