This is a migrated thread and some comments may be shown as answers.

ListBoxDragDropBehavior.AllowReorder fails

5 Answers 110 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Magnus
Top achievements
Rank 1
Magnus asked on 16 Mar 2017, 08:38 AM

Hi,

I'm using a simple setup with some items (just some strings) in a RadListBox with drag and drop to another RadListBox. The drag and drops works fine, but it seems like the property ListBoxDragDropBehavior.AllowReorder does not always work. As you can see I have set it to "false", and when dragging items in normal speed it prevents the items from being reordered. But if i drag and drop a bit more aggressively I can actually reorder the items within the same RadListBox. I added a custom implementation of the ListBoxDragDropBehavior with an override of CanDrop, but that method is never called when dragging aggressively. 

 

<TabItem Header="DragTest">
  <TabItem.Resources>
    <ResourceDictionary>
      <Style TargetType="telerik:RadListBoxItem"
           BasedOn="{StaticResource {x:Type telerik:RadListBoxItem}}">
        <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
      </Style>
    </ResourceDictionary>
  </TabItem.Resources>
  <telerik:RadListBox AllowDrop="True"
              ItemsSource="{Binding DragItems1}" >
    <telerik:RadListBox.DragVisualProvider>
      <telerik:ScreenshotDragVisualProvider />
    </telerik:RadListBox.DragVisualProvider>
    <telerik:RadListBox.DragDropBehavior>
      <telerik:ListBoxDragDropBehavior AllowReorder="False"/>
    </telerik:RadListBox.DragDropBehavior>
  </telerik:RadListBox>
</TabItem>

5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 20 Mar 2017, 04:51 PM
Hello,

I've tried to reproduce the problem you report, but to no avail. You can check the attached sample project which illustrates my attempt. Please note that I am using our latest official version - 2017.1.222. May I ask you to test with our latest version? It will be great if you can provide a video which demonstrates the unwanted behavior.

Regards,
Yoan
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Magnus
Top achievements
Rank 1
answered on 21 Mar 2017, 06:48 AM

Strange! I tried your code, and I can trigger the error with the latest version, 2017.1.222.

I've uploaded a screencapture of the behavior to my Google Drive:

https://drive.google.com/open?id=0B5M0ZK0lmfEQWlE3OUlBMWNNVUU

0
Yoan
Telerik team
answered on 23 Mar 2017, 05:13 PM
Hi,

Thank you for providing the video.

 I was able to reproduce the reported behavior. However, I will need additional time to investigate the problem. I'll get back to you as soon as we have more information on the matter.

Thank you for your understanding.

Regards,
Yoan
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Accepted
Nasko
Telerik team
answered on 27 Mar 2017, 04:08 PM
Hello Magnus,

We have investigated further the described issue and it is actually caused by the Framework itself. When you drag and drop really fast the items the visual elements that are part of the ListBoxItem's Template invoke the Drop event that reaches RadListBox.

So, what we could suggest you is to create a custom ListBoxDragDropBehavior and override the Drop method. Inside it you need to check if the CanDrop method returns True and if so to call the base implementation of the Drop method.

We have created a sample project that demonstrates the described above approach - please, check it.

Hope this helps.

Regards,
Nasko
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Magnus
Top achievements
Rank 1
answered on 28 Mar 2017, 06:55 AM

Thanks for the help, your solution works great. I already had a custom ListBoxDragDropBehavior (to disable copying items with the Ctrl-key) so it was a quick fix!

 

Thanks!

Tags
DragAndDrop
Asked by
Magnus
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Magnus
Top achievements
Rank 1
Nasko
Telerik team
Share this question
or