Hi,
i have two ListBoxes (in a Silverlight 3 Application), each wrapped with a ListBoxDragDropTarget. Now i fill the SourceBox with some custom Objects (Person). Then i wire up the DragOver Event of the Destination DragDtopTarget. This all workd fine and i can drag & drop the elements from the first list to the second.
Now my issue: How can i get the Element, which is being dragged to allow/disalow dragging? (I cannot get the Person from the FragEventArgs).
This is my Xaml:
<Grid x:Name="LayoutRoot" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<controlsToolkit:ListBoxDragDropTarget
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
x:Name="DragSource">
<ListBox x:Name="lbSource" DisplayMemberPath="Name" />
</controlsToolkit:ListBoxDragDropTarget>
<controlsToolkit:ListBoxDragDropTarget
Grid.Column="1"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
x:Name="DragDest"
msWindows:DragDrop.AllowDrop="true">
<ListBox x:Name="lbDest" DisplayMemberPath="Name" />
</controlsToolkit:ListBoxDragDropTarget>
and this is the Code of my DragOver-Handler:
Private Sub DragDest_DragOver(ByVal sender As Object, _
ByVal e As Microsoft.Windows.DragEventArgs) _
Handles DragDest.DragOver
Dim Pers = e.Data.GetData(GetType(Person))
End Sub
Thank you for any hints how to solve this.
Christoph
EDIT:
This is my short version of the Answer :-) :
Private Sub DragDest_DragOver(ByVal sender As Object, _
ByVal e As Microsoft.Windows.DragEventArgs) _
Handles DragDest.DragOver
Dim Args As ItemDragEventArgs = e.Data.GetData(e.Data.GetFormats()(0))
Dim Sel As SelectionCollection = Args.Data
Dim Persons = (From Pe In Sel Select DirectCast(Pe.Item, Person)).ToList
End Sub