Drag from SfDataGrid and Drop in ListView

Hi,

I am trying to implement dragging a row (object) from a sfdatagrid and dropping it (copying to) in another listview. I followed the demo here: https://help.syncfusion.com/uwp/datagrid/interactive-features#row-drag-and-drop-between-datagrid-and-listview

However, this does not work since only the ListView_DragEnter function is activated when I drag and drop to list view, the Drag Over and Drag Drop events does not get activated.

Thanks.

1 Reply 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team June 8, 2021 03:22 PM UTC

Hi Sam Shen,

Thank you for contacting Syncfusion Support.

Based on provided information we have checked the DragOver and DragDrop event of List view when drag the item in list view both events triggered properly. In this case, we drag the item from SfDataGrid ListView Drop event only triggered.  The reported problem not related to SfDataGrid. This related to MSDN ListView.

You can drop the item from SfDataGrid to ListView by customization Drop event of ListView. Please refer the below code snippet, 
private void ListView_Drop(object sender, DragEventArgs e) 
{ 
            if (e.DataView.Properties.ContainsKey("Records")) 
                records1 = e.DataView.Properties["Records"] as ObservableCollection<object>; 
 
            foreach (var item in records1) 
            { 
                //if you need to remove the item from SfDataGrid or not comment below line 
                this.datagrid.View.Remove(item as BusinessObjects); 
                //Dragged item added in ListView 
                (this.DataContext as ViewModel).GDCSource1.Add(item as BusinessObjects); 
            } 
} 
Please let us know if you have any concerns in this.

Regards,
Vijayarasan S 


Marked as answer
Loader.
Up arrow icon