Unable to perform drop function when trying to DragDrop

3 posts, 0 answers
  1. Dexter
    Dexter avatar
    34 posts
    Member since:
    Dec 2012

    Posted 22 Jul 2014 Link to this post

    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. Dexter
    Dexter avatar
    34 posts
    Member since:
    Dec 2012

    Posted 22 Jul 2014 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 23 Jul 2014 Link to this post

    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.
     
Back to Top