DnD not working since 2016.3.1024.45

3 posts, 0 answers
  1. Raul
    Raul avatar
    20 posts
    Member since:
    Apr 2014

    Posted 29 Oct Link to this post

    Hello,

    dnd between two gridviews is not working since the upgrade from 2016.3.914.45 to 2016.3.1024.45.

    In the OnDragInitialize methode I'm assigning a DnD object to eventargs.Data which is not recognized by the drop table "eventargs.Data.GetDataPresent()".
    It worked perfectly in the previous version but caused yesterday a lot of trouble after upgrading an application to the latest version :(

     

            private void OnDragInitialize(object sender, Telerik.Windows.DragDrop.DragInitializeEventArgs ea) {
                string displayText = "";
                var selectedRows = ((RadGridView)sender).SelectedItems;
                if (selectedRows.Count == 0) {
                    return;
                }

                var list = new List<PsCore.DataObjects.DragAndDrop.BusinessPartnerEntityDndDO>();
                foreach (PsCore.Interfaces.IDndDataObject row in selectedRows) {
                    list.Add(new PsCore.DataObjects.DragAndDrop.BusinessPartnerEntityDndDO(row.PrimaryID, row.DisplayText));
                    displayText = row.DisplayText;
                }
                ea.Data = new PsCore.DataObjects.DragAndDrop.DndContainerDO<PsCore.DataObjects.DragAndDrop.BusinessPartnerEntityDndDO>(list, displayText);

                ea.DragVisual = new ContentControl { ContentTemplate = LayoutRoot.Resources["DraggedItemTemplate"] as DataTemplate, Content = ea.Data };
                this.dragVisualTemp = ea.DragVisual;
                ea.DragVisualOffset = new Point(ea.RelativeStartPoint.X, ea.RelativeStartPoint.Y - 20);
                ea.AllowedEffects = DragDropEffects.All;
                ea.Handled = true;
            }



            private bool IsDndObjectAllowed(DragEventArgs ea) {
                Type dndContainerType = typeof(DndContainerDO<BusinessPartnerEntityDndDO>);
                if (!ea.Data.GetDataPresent(dndContainerType)) {
                    Console.WriteLine("DND object NOT recognized");
                    return false;
                }
                var draggedData = (ea.Data as DataObject).GetData(dndContainerType) as DndContainerDO<BusinessPartnerEntityDndDO>;
                if ((draggedData != null) && (draggedData.Items.GetType() == typeof(List<BusinessPartnerEntityDndDO>))) {
                    return true;
                }
                return false;
            }

    Best Regards,

    Raul

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 01 Nov Link to this post

    Hi Raul,

    Currently, we are investigating a similar report, so I will share our current observations on it. Please tell us whether they seem applicable to your scenario, or we should be looking somewhere else for the source of this issue.
    Some time ago we stumbled on a memory leak in DragDrop.DoDragDrop, which  can cause a massive memory footprint in some scenarios. In the SP version 2016.3.1024.45 we introduced a fix for it. To prevent the memory problem we decided to pass a WeakReference to the dragged data to the method, instead of the dragged data itself. To avoid a potential breaking change in the Telerik DragDrop events args, we added internal logic that deserializes the passed WeakReference and exposes the original drag data in the event arguments of Telerik DragDropManager's events. However, we cannot guarantee this for the original WPF DragDrop events, as we do not have direct control to this logic. Thus if one subscribes to UIElement.Drop instead of DragDropManager.Drop, the event arguments would contain the WeakRefence to the data instead of the data itslef. 
    I am attaching a sample project that I prepared regarding this scenario. It does not use RadGridView, but the logic should be pretty similar as DragDropManager should be completely control independent. The first option is to use UIElement.Drop, but uncomment the logic marked as workaround in the comments. The other one, which is recommended, is to stick to DragDropManager.Drop.

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 03 Nov Link to this post

    Hi,

    We found some possible scenarios that would be broken by this change, so we decided to revert it. The affected logic would be returned to its original state in the next week's internal build (Monday).

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Back to Top