ListBoxDragDropBehavior.AllowReorder fails

6 posts, 1 answers
  1. Magnus
    Magnus avatar
    23 posts
    Member since:
    Dec 2011

    Posted 16 Mar Link to this post

    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>
  2. Yoan
    Admin
    Yoan avatar
    1128 posts

    Posted 20 Mar Link to this post

    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 allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Magnus
    Magnus avatar
    23 posts
    Member since:
    Dec 2011

    Posted 21 Mar Link to this post

    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

  4. Yoan
    Admin
    Yoan avatar
    1128 posts

    Posted 23 Mar Link to this post

    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.
  5. Answer
    Nasko
    Admin
    Nasko avatar
    691 posts

    Posted 27 Mar Link to this post

    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.
  6. Magnus
    Magnus avatar
    23 posts
    Member since:
    Dec 2011

    Posted 28 Mar in reply to Nasko Link to this post

    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!

Back to Top