Issue with Drag&Drop in ListBox

1 posts, 0 answers
  1. Haidong
    Haidong avatar
    6 posts
    Member since:
    Sep 2011

    Posted 30 May 2012 Link to this post

    I use below code to create two list box and drag&drop listboxitem between this two list.
    Sometimes it works well. But sometime when I drag item from list1 to list2, the item can not be drop to the list2. The item go back to the list1.
    Please notice that I use Data template for the listboxitem and the data template is a little complex.

    Could someone help me on that?

    <Style TargetType="ListBoxItem"
                  x:Key="draggableItemStyle">
               <Setter Property="telerik:DragDropManager.AllowDrag"
                       Value="True" />
               <Setter Property="telerik:DragDropManager.AllowCapturedDrag"
                       Value="True" />
           </Style>


    <
    ListBox x:Name="MUL"
                                 ItemsSource="{Binding List1, Mode=TwoWay}"
                                 ItemContainerStyle="{StaticResource draggableItemStyle}"
                                 AllowDrop="True"
                                 Margin="10"
                                 BorderBrush="{StaticResource BorderColor}">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <controlsToolkit:WrapPanel Orientation="Horizontal"
                                                               Background="Transparent" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.Template>
                                <ControlTemplate TargetType="ListBox">
                                    <ScrollViewer HorizontalScrollBarVisibility="Disabled"
                                                  VerticalScrollBarVisibility="auto"
                                                  BorderThickness="0">
                                        <Grid Background="Transparent">
                                            <Border>
                                                <ItemsPresenter />
                                            </Border>
                                        </Grid>
                                    </ScrollViewer>
                                </ControlTemplate>
                            </ListBox.Template>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                      .......................
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                            <telerik:ListBoxDragDrop.Behavior>
                                <telerik:ListBoxDragDropBehavior />
                            </telerik:ListBoxDragDrop.Behavior>
                            <telerik:ListBoxDragDrop.DragVisualProvider>
                                <telerik:ScreenshotDragVisualProvider />
                            </telerik:ListBoxDragDrop.DragVisualProvider>
                        </ListBox>
Back to Top