Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to first convert the data object to an <code>ItemDragEventArgs</code> and then retrieve the SelectionCollection from it, which contains the item you've dragged. Pass your <code>e</code> parameter to this method and it should return you the items dragged.</p> <p>I used an online C# to VB converter, so hopefully it did a good enough job. Both VB and C# below.</p> <p>VB:</p> <pre><code> using System.Windows.Controls; using System.Linq; using System.Collections.ObjectModel; using System.Collections.Generic; #if SILVERLIGHT using SW = Microsoft.Windows; #else using SW = System.Windows; #endif Private Function GetSelectedPeople(ByVal args As SW.DragEventArgs) As IEnumerable(Of Person)     Dim people As IEnumerable(Of Person) = Nothing         ' Retrieve the dropped data in the first available format.     Dim data As Object = args.Data.GetData(args.Data.GetFormats()(0))         ' The data is the ItemDragEventArgs that was created by the DDT when     ' the drag started. It contains a SelectionCollection.     ' SelectionCollection's are used by DDTs because they can transfer     ' multiple objects. The fact that they store the indexes of the     ' objects within the source collection also makes reordering items     ' within a source possible.     Dim dragEventArgs As ItemDragEventArgs = TryCast(data, ItemDragEventArgs)     Dim selectionCollection As SelectionCollection = TryCast(dragEventArgs.Data, SelectionCollection)     If selectionCollection IsNot Nothing Then         people = selectionCollection.[Select](Function(selection) selection.Item).OfType(Of Person)()     End If         Return people End Function </code></pre> <p>C#:</p> <pre><code> using System.Windows.Controls; using System.Linq; using System.Collections.ObjectModel; using System.Collections.Generic; #if SILVERLIGHT using SW = Microsoft.Windows; #else using SW = System.Windows; #endif private IEnumerable&lt;Person&gt; GetSelectedPeople(SW.DragEventArgs args) { IEnumerable&lt;Person&gt; people = null; // Retrieve the dropped data in the first available format. object data = args.Data.GetData(args.Data.GetFormats()[0]); // The data is the ItemDragEventArgs that was created by the DDT when // the drag started. It contains a SelectionCollection. // SelectionCollection's are used by DDTs because they can transfer // multiple objects. The fact that they store the indexes of the // objects within the source collection also makes reordering items // within a source possible. ItemDragEventArgs dragEventArgs = data as ItemDragEventArgs; SelectionCollection selectionCollection = dragEventArgs.Data as SelectionCollection; if (selectionCollection != null) { people = selectionCollection.Select(selection =&gt; selection.Item).OfType&lt;Person&gt;(); } return people; } </code></pre> <p>Reference: <a href="http://themechanicalbride.blogspot.com/2009/10/silverlight-drag-drop-support-part-2.html" rel="nofollow noreferrer">http://themechanicalbride.blogspot.com/2009/10/silverlight-drag-drop-support-part-2.html</a></p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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