How do I enable drag re-ordering without drop?

2 posts, 0 answers
  1. Chris
    Chris avatar
    30 posts
    Member since:
    Oct 2010

    Posted 16 Oct 2013 Link to this post

    I have a single RadListBox and I just want to enable drag re-ordering with no drop capabilities (the documentation is this area is horribly unclear).

    I have the following XAML:

    <tel:RadListBox ItemsSource="{Binding Path=DtedDirectories}"
                    SelectedValue="{Binding Path=SelectedDtedDirectory}"
            <Style TargetType="tel:RadListBoxItem">
                <Setter Property="tel:DragDropManager.AllowCapturedDrag" Value="True" />
            <tel:ListBoxDragDropBehavior AllowReorder="True" />

    The problem I have is that the list box will let me drop items outside of it, thus removing the item from the list.  I do not want this behavior.
  2. Rosen Vladimirov
    Rosen Vladimirov avatar
    640 posts

    Posted 18 Oct 2013 Link to this post

    Hello Chris,

    The items will be removed from RadListBox only when you drop the dragged item over an element which has AllowDrop property set to true. In this case this element (the one over which you have dropped the list box item) will receive Drop event and the ListBox will be notified that there was successful drop operation and it will remove the item from its source. In this case you have two options - first one is to remove AllowDrop="true" from all the other controls. The other one is to use DragOver event of all controls that have AllowDrop = true. In this case you can check the dragged data and check its type. If it is from the same type as the items in RadListBox, you can set the effects of the operation to None and this way you'll prevent dropping. For this scenario you have to use DragDropManager. I'm sending you a sample project demonstrating the exact approach.  Please check it and inform us in case you have any problems or concerns.

    Rosen Vladimirov
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top