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

RadListBox drag and drop wierd behaviour

1 Answer 161 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Marouane
Top achievements
Rank 1
Marouane asked on 17 Sep 2013, 10:03 AM
I'm working on a screen with WPF which has 3 listbox (list1, list2, list3), and i can drag items from list1 to list2 and list2 to list3 or even list1 to list3, and i can do it reversely.

I had to change the listbox (list3) to radListBox, because i wanted to implement the reorder within this list, i managed that drag and drop worked, and it did. but when a i wanted to drag an item from list3 (radlistbox), i got null in this variable :
" var data = ((DataObject)args.Data).GetData("DragData") as UcFileColumn", which UcFileColumn is a user control that i wanna cast with to drop in other lists. So insted od using "data" i thought using then selectedItem property to take the item dragged, and it works. Still one mysterious behaviour occured, is that when i dropped items in the lists3 (radListBox) and then drag them back into the lists(list1 or list2), and i wanted to dropped them back, the list prevent me to drop, i think when i remove item from teh radlistbox, the allowdrag dosent set anymore !!!!, is that because i used SelectedItem, if yes how should i get the element dragged from (DataObject)args.Data).GetData..

here is my XAML CODE : 

<UserControl.Resources>
        <Style x:Key="DraggableListBoxItem" TargetType="controls4:RadListBoxItem">
            <Setter Property="dragDrop:DragDropManager.AllowCapturedDrag" Value="True" />
            <Setter Property="dragDrop:DragDropManager.AllowDrag" Value="True" />
        </Style>
    </UserControl.Resources>
<ListBox Grid.Row="2" x:Name="List1"  ItemsSource="{Binding Source1, Mode=TwoWay}" AllowDrop="True" IsSynchronizedWithCurrentItem="True"
                     Style="{StaticResource ListBoxStyleMenu}" Margin="2,2,2,2"
                     VerticalAlignment="Stretch" HorizontalContentAlignment="Center" HorizontalAlignment="Stretch">
 
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid Columns="2" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="{x:Type ListBoxItem}">
                            <Setter Property="Focusable" Value="False"/>
                            <Setter Property="Margin" Value="0,5,0,5" />
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
<ListBox Grid.Row="2" x:Name="List2"  ItemsSource="{Binding Source2, Mode=TwoWay}" AllowDrop="True" IsSynchronizedWithCurrentItem="True"
                     Style="{StaticResource ListBoxStyleMenu}" Margin="2,2,2,2"
                     VerticalAlignment="Stretch" HorizontalContentAlignment="Center" HorizontalAlignment="Stretch">
 
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid Columns="2" />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="{x:Type ListBoxItem}">
                            <Setter Property="Focusable" Value="False"/>
                            <Setter Property="Margin" Value="0,5,0,5" />
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
<controls4:RadListBox x:Name="List3"  ItemsSource="{Binding Source3}" AllowDrop="False" SelectedItem="{Binding SourceSelected, Mode=TwoWay}"
                     VerticalAlignment="Stretch" HorizontalContentAlignment="Center" HorizontalAlignment="Stretch"
                    Margin="2,2,2,2" ItemContainerStyle="{StaticResource DraggableListBoxItem}">
                <controls4:RadListBox.DragDropBehavior>
                    <behaviors:ListBoxDragDropBehavior AllowReorder="True" dragDrop:DragDropManager.TouchDragTrigger="TapAndHold" />
                </controls4:RadListBox.DragDropBehavior>
 </controls4:RadListBox>


I'm looking forward for your response

1 Answer, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 20 Sep 2013, 06:33 AM
Hi Marouane,

If you need to implement DragDrop between several ListBoxes I suggest you to use our integrated ListBoxDragDropBehavior. If the data in the ListBoxes is of different type, you can use converter in order to convert it between the formats.

I've tried to reproduce your problem based on your code, but I couldn't. I'm sending you my test project, could you check it and inform us what else should be done to reproduce the issue?

I'm looking forward to hearing from you.

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
Marouane
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Share this question
or