RadListBox drag and drop wierd behaviour

2 posts, 0 answers
  1. Marouane
    Marouane avatar
    1 posts
    Member since:
    Sep 2013

    Posted 17 Sep 2013 Link to this post

    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

  2. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 20 Sep 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top