Drag and drop not working in UWP

Hi,

I'm currently building an App for Android and UWP that uses drag and drop in order to sort a SfListView. In Android everything works as expected. The UWP App crashes with a NotImplementedException (see below). Also it seems that with UWP I can only use the DragStartMode 'OnDragIndicator' as 'OnHold' does not seem to initialize the dragging operation ... or just does not work with a mouse click.


System.NotImplementedException: The method or operation is not implemented.
   at Syncfusion.DataSource.DisplayItems.CopyTo(Object[] array, Int32 arrayIndex)
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Collections.ObjectModel.ObservableCollection`1.CreateCopy(IEnumerable`1 collection, String paramName)
   at System.Collections.ObjectModel.ObservableCollection`1..ctor(IEnumerable`1 collection)
   at Syncfusion.ListView.XForms.DragDropController.ProcessDragStarted

Syncfusion version is 15.4.0.17

Did I miss something on the UWP side (initialization, etc.)?

Best regards
Michael

17 Replies

MK Muthu Kumaran Gnanavinayagam Syncfusion Team December 4, 2017 10:34 AM UTC

Hi Michael, 
 
We have checked the reported query “SfListView’s item drag and drop does not work when perform by mouse in UWP platform” from our side. We regret to inform you that SfListView do not have support to “perform the drag and drop by mouse in holding”. Since there is no long pressed events (like Holding event in touch) for the mouse in UWP framework. So SfListView.DragStartMode property does not work with ‘OnHold’ value in UWP platform.  
 
However you can use ‘OnDragIndicator’ which allows you to perform drag and drop by loading the DragIndicatorView within ItemTemplate. 
 
If you want to use both OnHold and OnDragIndicator values in your application, you can set to both the values to DragStartMode property as like below codes. 
 
Code Example[C#]: 
listView.DragStartMode = DragStartMode.OnHold | DragStartMode.OnDragIndicator; 
 
Code Example[XAML]: 
<syncfusion:SfListView x:Name="listView" 
                       ItemSize="60" 
                       ItemsSource="{Binding ToDoList}" 
                       DragStartMode="OnHold,OnDragIndicator" 
                       SelectionMode="None"> 
 
For your reference, we have attached the working sample video along with the sample in the link below. 
 
 
Based on the stack trace, we have noticed that the Exception had been thrown from CopyTo method of DisplayItems, which we hasn’t provided support yet.  
So can you please share the details of your requirement and the usage of CopyTo method in your application or provide us a sample which replicates the reported issue? 
 
Regards, 
G.Muthu Kumaran. 



JO Joe January 16, 2018 02:39 AM UTC

I have this exact issue. Wheither I choose onHold or OnDragIndicator, when I click on the cell in UWP desktop it crashes with the same exception. I downloaded your sample application and it runs perfectly on UWP desktop. I can click and hold and it doesn't crash but doesn't reorder (which is fine) and dragging by the indicator works. I don't see anything different in code than mine.

What prevents the example from not crashing on click of the drag indicator?

Installed SFList from nuget.


MK Muthu Kumaran Gnanavinayagam Syncfusion Team January 16, 2018 12:45 PM UTC

Hi Joe,   
   
If you are facing the same stack trace like “Not Implemented Exception” when trying to copy data by CopyTo method, as we have stated in our previous update, we haven’t provided support for copying data from one into another based on its Index by using CopyTo method in DisplayItems. Else, can you please provide us more information about reported issue or your requirement, which would be helpful for us to resolve the issue at our end or we will provide details based on requirement.   
   
Regards,   
G.Muthu kumaran.   



JO Joe replied to Muthu Kumaran Gnanavinayagam January 17, 2018 03:31 AM UTC

Hi Joe,   
   
If you are facing the same stack trace like “Not Implemented Exception” when trying to copy data by CopyTo method, as we have stated in our previous update, we haven’t provided support for copying data from one into another based on its Index by using CopyTo method in DisplayItems. Else, can you please provide us more information about reported issue or your requirement, which would be helpful for us to resolve the issue at our end or we will provide details based on requirement.   
   
Regards,   
G.Muthu kumaran.   


I'm not trying to copy data, at least not intentionally. I'm following the example located here: https://help.syncfusion.com/xamarin/sflistview/item-drag-and-drop

The example project you posted in this thread DOES work exactly the way I thought it would on UWP. I do not understand why mine crashes the exact moment I click on the drag indicator label I made.

Shared code is .NET Standard 2.0.

My list view:

       
           
               
                   
                       
                           
                                                        Aspect="AspectFill" >
                           
                               
                               
                               
                                    HorizontalOptions="Center" 
                                    VerticalOptions="Center">
                                   
                               
                           
                       
                   
               
           
       
   


JO Joe January 17, 2018 03:33 AM UTC

 <ContentPage.Content>
        <syncfusion:SfListView x:Name="photoListView" ItemsSource="{Binding Photos}" DragStartMode="OnHold,OnDragIndicator" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <syncfusion:SfListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell Height="150">
                        <ViewCell.ContextActions>
                            <MenuItem Command="{Binding BindingContext.DeleteCommand, Source={x:Reference Name=PhotoListPage}" Text="Delete" IsDestructive="True"
                                          CommandParameter="{Binding .}"/>
                        </ViewCell.ContextActions>
                        <StackLayout Orientation="Horizontal" Spacing="20">
                            <ffimageloading:CachedImage Source="{Binding PhotoURL}" DownsampleToViewSize="true" WidthRequest="150" HeightRequest="150" 
                                                        Aspect="AspectFill"></ffimageloading:CachedImage>
                            <StackLayout HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand">
                                <Label Text="{Binding PhotoInformationText}" />
                                <Label Text="{Binding PhotoInformationDetail}" />
                                <syncfusion:DragIndicatorView ListView="{x:Reference photoListView}" 
                                    HorizontalOptions="Center" 
                                    VerticalOptions="Center">
                                    <Label Text="Drag Me"></Label>
                                </syncfusion:DragIndicatorView>
                            </StackLayout>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </syncfusion:SfListView.ItemTemplate>
        </syncfusion:SfListView>
    </ContentPage.Content>


JO Joe January 17, 2018 04:28 AM UTC

I just updated the sample project you gave to the latest version of SfListview and core and datasource and gridcommon (which is 15.4.0.20) and now the sample crashes as well when doing anything with the list view.

15.4.0.17 in the demo worked correctly.


MK Muthu Kumaran Gnanavinayagam Syncfusion Team January 18, 2018 11:50 AM UTC

Hi Joe,   
   
We have updated our documentation samples to latest version (v.15.4.0.20) of SfListView for our drag and drop samples and tried to replicate the same exception at our end, but the reported NotImplementedException is not thrown from the CopyTo method of DisplayItems.    
   
Pease share the entire stack trace of the reported exception which helps to analyze the cause of the issue:  
  
If possible can you please share a simple sample which reproduces the reported issue and also share the details of the tested device which will be highly helpful in resolving the issue at our end.   
Also please provide more details on the following  
  • Please confirm whether you have used sorting or grouping in your application
  • Whether the reported issue occurs in UWP platform alone? We have checked in android, iOS and UWP platforms. In UWP, we have provided support for holding items using mouse button from our SfListView(v.15.4.0.20). So we have checked by holding mouse left button and also by dragging the indicator.
  • Whether you are trying to perform any particular action in ItemDragging event?
   
We have referred the attached code example and found that you have used ContextActions for the ItemTemplate of SfListView. Currently ContextActions support is not provided in SfListView. However you can achieve this in application level. We have already published a KB documentation for the same and you can refer it from the below link.   
   
   
Please let us know if you require further assistance.   
   
Regards,   
G.Muthu kumaran.   



AK Avgerinos K January 23, 2018 03:03 PM UTC

I'm also facing the same issue.
Maybe i can give you a hint on how to reproduce this on the sample project. It appears that the CopyTo Method is only called when the application targets the latest target version of Windows and uses the latest version of Microsoft.NETCore.UniversalWindowsPlatform.
These are the steps i performed on the sample SfListView Project to reproduce the error :

1. Updated the UWP project target version and minimum version to Fall Creators Update
2. Updated Nuget Package Microsoft.NETCore.UniversalWindowsPlatform to the latest stable version 6.0.6
3.Updated Xamarin Forms to the latest stable version(although i dont think that this really matters)

After this i ran the sample list reordering and after long press on a list element to begin the drag n drop the mentioned exception appears. Below is the stack trace :

System.NotImplementedException: The method or operation is not implemented.
   at Syncfusion.DataSource.DisplayItems.CopyTo(Object[] array, Int32 arrayIndex)
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Collections.ObjectModel.ObservableCollection`1.CreateCopy(IEnumerable`1 collection, String paramName)
   at System.Collections.ObjectModel.ObservableCollection`1..ctor(IEnumerable`1 collection)
   at Syncfusion.ListView.XForms.DragDropController.ProcessDragStarted



MK Muthu Kumaran Gnanavinayagam Syncfusion Team January 24, 2018 04:47 PM UTC

Hi Avgerinos, 
 
We have followed the exact replication procedure and tried to reproduce the reported issue in our UG documentation item reordering sample with latest version of SfListView(v.15.4.0.20). But we could not reproduce the same issue at our end. As we have mentioned in our previous updates, we haven’t provided support for copying data from one to another based on its Index by using CopyTo method in DisplayItems. So could you please share the sample which reproduces the reported issue which would be highly helpful for us to validate and resolve the reported issue at our end. 
 
Regards, 
G.Muthu kumaran. 



JO Joe replied to Muthu Kumaran Gnanavinayagam January 24, 2018 07:54 PM UTC

Hi Avgerinos, 
 
We have followed the exact replication procedure and tried to reproduce the reported issue in our UG documentation item reordering sample with latest version of SfListView(v.15.4.0.20). But we could not reproduce the same issue at our end. As we have mentioned in our previous updates, we haven’t provided support for copying data from one to another based on its Index by using CopyTo method in DisplayItems. So could you please share the sample which reproduces the reported issue which would be highly helpful for us to validate and resolve the reported issue at our end. 
 
Regards, 
G.Muthu kumaran. 


I followed avgerinos instructions and was able to get the same error on the sample project. I first opened the projected and updated all syncfusion products, then universal windows, and finally xam forms. Then I opened the UWP app project files and changed the sdk and min version to creators update. I have it like this because the project I'm currently working on requires creators update for .net standard 2.0, which is all Xamarin allows you to create when you create a new project. I'm attaching the project WITHOUT the packages folder as it's over the limit allowed (30mbs). I believe you can restore packages when you get it. I'll try to upload my packages file separately.

Since you asked for the stack trace:

   at Syncfusion.DataSource.DisplayItems.CopyTo(Object[] array, Int32 arrayIndex)
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Collections.ObjectModel.ObservableCollection`1.CreateCopy(IEnumerable`1 collection, String paramName)
   at System.Collections.ObjectModel.ObservableCollection`1..ctor(IEnumerable`1 collection)
   at Syncfusion.ListView.XForms.DragDropController.ProcessDragStarted(ListViewItemInfoBase itemInfo, Point point, Point touchPosition)
   at Syncfusion.ListView.XForms.DragDropController.HandleTouchInteractions(ListViewItemInfoBase itemInfo, GestureStatus status, Point point, Point touchPosition)
   at Syncfusion.ListView.XForms.UWP.DragIndicatorViewRenderer.DragIndicatorViewRenderer_PointerPressed(Object sender, PointerRoutedEventArgs e)

My PC is a custom built desktop PC running Windows 10 on the latest windows updates. To answer some of your questions:

  • Please confirm whether you have used sorting or grouping in your application
          I have not.
  • Whether the reported issue occurs in UWP platform alone? We have checked in android, iOS and UWP platforms. In UWP, we have provided support for holding items using mouse button from our SfListView(v.15.4.0.20). So we have checked by holding mouse left button and also by dragging the indicator.
          Seems to just be UWP. I only tried iOS besides that one and iOS was fine.
  • Whether you are trying to perform any particular action in ItemDragging event?
          I haven't wrote any code yet for that but what I will be doing is when the dragging stops, send a web request to the server to reorder them on the backend.

Attachment: DragAndDropUWP_updated_e099eff7.zip


JO Joe January 24, 2018 08:03 PM UTC

Two things:

1. I tried changing the ObserableCollection to a List and got the same error.
2. I was unable to upload the packages folder as even zipped, it's 33 mbs.


DB Dinesh Babu Yadav Syncfusion Team January 26, 2018 07:07 AM UTC

Hi Joe, 
 
Apologies for the inconvenience. 
 
Based on the given information and sample, we have checked the reported issue and suspect that the issue may occur due to SfListView’ s dependency assemblies are not referred properly in UWP renderer project.  
 
So, we suggest you to refer the following UG documentation link for more reference about list of assemblies needed to render the SfListView control in respective renderer platforms. 
 
 
Also, in the given sample the nuget packages are not referred properly. So, we have manually referred the packages from Syncfusion Nuget to analyze the issue but the items are rearranged as expected when drag and drop action is performed. For your reference, we have attached the ensured sample at our end and you can download it from the below link. 
 
 
Please let us know if you require further assistance. 
 
Dinesh Babu Yadav 
 



AK Avgerinos K January 26, 2018 11:35 AM UTC

Ok i've redownloaded the sample drag and drop project from your link.
I've opened it build and run and everything run normally at this point. Then i set the target version to fall creators update and updated all nuget packages to the latest version.
Then i rebuilded and still everything seemed ok.

And then finally i went on to the project properties and switched the project Min version also to falls creators update. And then after rebuilding the problem showed up.  Also it may be possible that the version of the operating system affects it. I'm running on windows 10 version 1709.

Attached you will find my modified sample

I hope that you can finally reproduce it with this






Attachment: DragAndDrop_Modified_d2a2fe2e.zip


JO Joe replied to Dinesh Babu Yadav January 27, 2018 02:31 AM UTC

Hi Joe, 
 
Apologies for the inconvenience. 
 
Based on the given information and sample, we have checked the reported issue and suspect that the issue may occur due to SfListView’ s dependency assemblies are not referred properly in UWP renderer project.  
 
So, we suggest you to refer the following UG documentation link for more reference about list of assemblies needed to render the SfListView control in respective renderer platforms. 
 
 
Also, in the given sample the nuget packages are not referred properly. So, we have manually referred the packages from Syncfusion Nuget to analyze the issue but the items are rearranged as expected when drag and drop action is performed. For your reference, we have attached the ensured sample at our end and you can download it from the below link. 
 
 
Please let us know if you require further assistance. 
 
Dinesh Babu Yadav 
 


Dinesh, the sample you provided wasn't updated to the latest versions as we mentioned. Xamarin forms and Universial windows platform was out of date on nuget. Once I downloaded the project and set the target and min windows version to the creators update, I got the crash again.

I got the same results as Avgerinos.


DB Dinesh Babu Yadav Syncfusion Team January 30, 2018 11:42 AM UTC

Hi Joe, 
 
Apologies for the inconvenience. 
 
We could able to reproduce the reported issue at our end and we have logged a defect report for this. The fix for the issue will be included in our 2018 Volume 1 SP 1 release and will let you know once the issue has been resolved and included in the release. We will appreciate your patience until then. 
 
Dinesh Babu Yadav 
 



JO Joe replied to Dinesh Babu Yadav January 31, 2018 01:03 PM UTC

Hi Joe, 
 
Apologies for the inconvenience. 
 
We could able to reproduce the reported issue at our end and we have logged a defect report for this. The fix for the issue will be included in our 2018 Volume 1 SP 1 release and will let you know once the issue has been resolved and included in the release. We will appreciate your patience until then. 
 
Dinesh Babu Yadav 
 


Do you have an idea on the timeframe that may be released? This is the only thing holding my app back at the moment.


MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 1, 2018 12:36 PM UTC

Hi Joe, 
 
You can follow up the incident created under your account for further updates. 
 
Regards, 
G.Muthu kumaran. 


Loader.
Up arrow icon