Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i get the Dragged Element in a Silverlight App
    primarykey
    data
    text
    <p>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 &amp; drop the elements from the first list to the second.</p> <p>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).</p> <p>This is my Xaml:</p> <pre><code>&lt;Grid x:Name="LayoutRoot" Background="White"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;controlsToolkit:ListBoxDragDropTarget HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="DragSource"&gt; &lt;ListBox x:Name="lbSource" DisplayMemberPath="Name" /&gt; &lt;/controlsToolkit:ListBoxDragDropTarget&gt; &lt;controlsToolkit:ListBoxDragDropTarget Grid.Column="1" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="DragDest" msWindows:DragDrop.AllowDrop="true"&gt; &lt;ListBox x:Name="lbDest" DisplayMemberPath="Name" /&gt; &lt;/controlsToolkit:ListBoxDragDropTarget&gt; </code></pre> <p></p> <p>and this is the Code of my DragOver-Handler:</p> <pre><code>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 </code></pre> <p>Thank you for any hints how to solve this.</p> <p>Christoph</p> <p>EDIT:</p> <p>This is my short version of the Answer :-) :</p> <pre><code>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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload