We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Drag&Drop from TreeView to SfTextBoxExt

Hello,


we are currently try to implement and Drag&Drop-functionality in our program. Therefor, we have an SfTreeView for scene content, where every object in our scene is shown. One of our Data-ViewModels contains information about this object and we implemented an SfTextBoxExt to search for scene objects (same one as in our SfTreeView). This works perfectly, but we also want to be able to Drag scene objects from the SfTreeView into the SfTextBoxExt, where we want to drop it there. However. this is not working as intended, because the SfTextBoxExt doesn't seem to be notified about any drag/drop-events. We implemented this features as Behavior, so the Drag-Behavior (attached) will be called when start dragging from the SfTreeView (works, as intended) and dropped it's content to any UIElement (not working for SfTextBoxExt).

The SfTextBox itself is embedded into an SfAccordion, which itself is attached as an UserControl into an DockingManager. Add the Drop-Behavior to the SfTextBoxExt doesn't recognize any events, the SfAccordion however (when the behavior is attached to it), the DragEnter-Callback is called, but not the Drop-Event.


I read, that Drag&Drop-Behaviors from SfTreeView is allowed to ListView, Diagram and SfDataGrid. So the question is, if it is overall not possible to add this behavior to an SfTextBoxExt? And if so, are there any workarounds to implement this feature in any other way?








Attachment: Behaviors_95f2cc9e.7z

4 Replies

SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 22, 2024 02:26 PM UTC

Hi Christian, 

We are currently analyzing regarding the notification of the drop event in the SfTextBoxExt control. We need some time to validate regarding this and we will update you further details on or before April 24, 2024.

Regards,
Sreemon Premkumar M. 



SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 24, 2024 08:03 AM UTC

Hi Christian,

In SfTextboxExt, we did not handle the drop event from our side. Additionally, this issue was replicated in the framework TextBox. After searching through various online resources, we discovered a workaround to address this issue by notifying the drop event in the TextBox control. The workaround involves subscribing to the PreviewDragOver event and setting 'e.Handle' to true, allowing the Drop event to be executed. Please find the code snippet below.

Code snippet:

private void textboxext_Drop(object sender, DragEventArgs e)

{

    MessageBox.Show("Dropped on SfTextBoxExt.");

}

private void textboxext_PreviewDragOver(object sender, DragEventArgs e)

{

    e.Handled = true;

}


You can find the workaround in this link.

We have prepared the sample based on it. Please find it in the attachment.

Regards,
Sreemon Premkumar M.


Attachment: SfTreeViewDragandDrop_62868141.zip


CH Christian April 24, 2024 02:35 PM UTC

Hi Sreemon,


many thanks for looking into it and indeed, the PreviewDragOver did the trick for us! We could finally solve our problem with your example shared.


Much appreciated!


Best

Christian



SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 25, 2024 05:14 AM UTC

Hi Christian,

We hope that your issue has been resolved with our proposed workaround, please get back to us if you need further assistance. We are happy to help you.

Regards,
Sreemon Premkumar M.


Loader.
Live Chat Icon For mobile
Up arrow icon