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

Unable to perform drop function when trying to DragDrop

2 Answers 42 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Dexter
Top achievements
Rank 1
Dexter asked on 22 Jul 2014, 08:39 AM
Hello, I would like to perform Drag & Drop function from one ListBox to another ListBox as documented in this link:
http://www.telerik.com/help/wpf/radlistbox-features-dragdrop.html

However, it is not working for me. I'm able to drag items, but nothing happens while dropping. Maybe the documentation is clear enough of the necessary configurations needed for the ListBox which you want to drag items from, and the ListBox which you want to drop items to.

Here are my codes:
(ListBox I want to drag from)
<telerik:RadListBox Margin="5,5,5,5" Grid.Column="0" Grid.Row="3"
                                    x:Name="listBoxItems" HorizontalAlignment="Left" VerticalAlignment="Top" Width="250"
                                    ItemsSource="{Binding}" ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                                    ItemTemplate="{StaticResource ListBoxCustomTemplate}" SelectionMode="Multiple"
                                    TextPath="Serial">
                    <telerik:RadListBox.DragVisualProvider>
                        <telerik:ScreenshotDragVisualProvider />
                    </telerik:RadListBox.DragVisualProvider>
                    <telerik:RadListBox.DragDropBehavior>
                        <telerik:ListBoxDragDropBehavior />
                    </telerik:RadListBox.DragDropBehavior>
                     
                </telerik:RadListBox>

(ListBox I want to drag to)
<telerik:RadListBox Grid.Row="0" Grid.Column="2" Margin="0, 5, 5, 5"
                x:Name="listBoxIssue" HorizontalAlignment="Left" VerticalAlignment="Top"
                Height="690" Width="793" ItemsSource="{Binding}" ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                                    ItemTemplate="{StaticResource ListBoxCustomTemplate}">
                <telerik:RadListBox.DragVisualProvider>
                    <telerik:ScreenshotDragVisualProvider />
                </telerik:RadListBox.DragVisualProvider>
                <telerik:RadListBox.DragDropBehavior>
                    <telerik:ListBoxDragDropBehavior />
                </telerik:RadListBox.DragDropBehavior>
            </telerik:RadListBox>

2 Answers, 1 is accepted

Sort by
0
Dexter
Top achievements
Rank 1
answered on 22 Jul 2014, 06:46 PM
Alright I have found the culprit. Simply, ItemsSource is causing all the problems - receiving listbox unable to receive drop items, and 'giving' listbox started behaving weirdly after giving one of its item. I just basically remove ItemsSource on both.
Instead of assigning List<Object> to its ItemsSource, I just loop through the List<Object> and add each Object to RadListBox.Items instead.

This is the current workaround which I don't forsee any disadvantage for now. If there's a more efficient method, please enlighten me =)

With this fixed, I'm going to go all complicated with the listboxes, including various data convert between listbox. I have done a bit of that and everything is still fine for now. When any complications occur again, I'll be posting back.
0
Kalin
Telerik team
answered on 23 Jul 2014, 01:30 PM
Hi Dexter,

In the case when changing the ItemsSource at run-time you should use ObservableCollection instead of List. This way the UI will be notified whenever the underlying collection is changed.

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ListBox
Asked by
Dexter
Top achievements
Rank 1
Answers by
Dexter
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or