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

How do I enable drag re-ordering without drop?

1 Answer 62 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 16 Oct 2013, 03:30 PM
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}"
                SelectionMode="Single">
    <tel:RadListBox.ItemContainerStyle>
        <Style TargetType="tel:RadListBoxItem">
            <Setter Property="tel:DragDropManager.AllowCapturedDrag" Value="True" />
        </Style>
    </tel:RadListBox.ItemContainerStyle>
    <tel:RadListBox.DragDropBehavior>
        <tel:ListBoxDragDropBehavior AllowReorder="True" />
    </tel:RadListBox.DragDropBehavior>
</tel:RadListBox>

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.

1 Answer, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 18 Oct 2013, 03:19 PM
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.

Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
Tags
ListBox
Asked by
Chris
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Share this question
or