views:

343

answers:

2

I tried to get Drag and Drop working between two ListBox Controls. But somehow picking up an item is not possible.

Maybe you have a hint for me to get it working

My User Control xaml code looks like this:

 <UserControl.Resources>
    <DataTemplate x:Key="ItemTemplate">
        <StackPanel Orientation="Horizontal">
            <Image Width="20" Height="20" Source="{Binding Path=pic}"></Image>
            <TextBlock Text="{Binding Path=name}"></TextBlock>
        </StackPanel>
    </DataTemplate>
</UserControl.Resources>
<StackPanel>
    <Grid x:Name="LayoutRoot" Height="352" Width="435">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="300"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="30"/>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="5*" />
        </Grid.ColumnDefinitions>

        <TextBlock Text="All Friends" Grid.Column="0" Grid.Row="0"/>
        <controlsToolkit:ListBoxDragDropTarget Grid.Column="0" Grid.Row="1" AllowDrop="true" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
            <ListBox x:Name="FriendsListBox" SelectionMode="Extended" ItemTemplate="{StaticResource ItemTemplate}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </controlsToolkit:ListBoxDragDropTarget>

        <TextBlock Text="Friends with access to room" Grid.Column="2" Grid.Row="0"/>
        <controlsToolkit:ListBoxDragDropTarget Grid.Column="2" Grid.Row="1" AllowDrop="true" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
            <ListBox x:Name="AllowedFriendsListBox" SelectionMode="Extended" ItemTemplate="{StaticResource ItemTemplate}">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </controlsToolkit:ListBoxDragDropTarget>
    </Grid>

</StackPanel>

I am binding my first ListBox to a IList of Facebook friend users.

It should be possible to drag and drop friends from one ListBox to the other.

I hope you can help me. Thanks in advance

A: 

Ok seems there is an issue using Drag and Drop in a Child Window:

http://silverlight.codeplex.com/WorkItem/View.aspx?WorkItemId=4494

Ben
+1  A: 

Not sure if you have rechecked that work item, it looks like someone has uploaded a patch for it recently which you could try out.

Druzil