TreeListBox and file drag drop

Grids for WPF Forum

Posted 8 months ago by Dirk Zellerfeld
Version: 18.1.0675
Platform: .NET 4.7
Environment: Windows 10 (64-bit)
Avatar

Hi,

when using the TreeListBoxItemAdapter allowing drag an drop of tree items, we are no longer able to handle file drag drop. The drop events of the TreeListBox are never raised, instead the drop event of the TreeListBoxItemAdapter is raised but we cannot handle the file drag drop there as its too specific. Is there a way we raise the treelistbox drop event within the drop event of the treelistboxitemadapter?

Comments (3)

Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Dirk,

We have to handle all the normal drag and drop events of the TreeListBox control ourselves so that we can properly support dragging over items and integrating with the item adapter.  The item adapter is where all logic for drag/drop needs to be placed.

May I ask why putting your Drop event logic in the item adapter's OnDrop method is an issue?

On a side note, you are passsed the TreeListBox reference to that OnDrop method.  So you can at least get at it from there.


Actipro Software Support

Posted 8 months ago by Dirk Zellerfeld
Avatar

We use one TreeListBoxItemAdapter for multiple treelistboxes. Its a generic class to handle basic drag drops of items and works fine using it like that. But for external file drag drop only one Treelistbox control needs to handle file drag drops. Thus we would like to handle it in the code of the treelistbox events rather than in the global treelistboxitemadapter.

The treelistbox ondrop is private. I don't see a way to simply invoke the ondrop event within the adapter ondrop event. We had hoped we can simply invoke the base treelist ondrop event and let it handle the file drag drop (or not). It would make it easier to maintain the source

Answer - Posted 8 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Dirk,

TreeListBox.OnDrop is a protected virtual method.  If unhandled, it is overridden to call into the item adapter's OnDrop method.  

Since all drag/drop handling should be done in the item adapter, my suggestion for you would be to put a custom attached property on that one particular TreeListBox to indicate that it requires file drag/drop processing.  Then have your item adapter drag/drop methods look for that attached property to know if that additional functionality should be enabled.  That would allow you to continue having a single item adapter for all your TreeListBox instances.

As a quicker alternative to the custom attached property, you could set some value to the TreeListBox.Tag property to indicate if that particular TreeListBox requires file drag/drop processing.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.