Beispiel #1
0
 static void gallery_Drop(object sender, DragEventArgs e)
 {
     e.Handled = true;
     if (dragableItem != null)
     {
         HitTestResult res = VisualTreeHelper.HitTest((GalleryControl)sender, e.GetPosition((GalleryControl)sender));
         if (res.VisualHit == null)
         {
             return;
         }
         GalleryItemControl target = LayoutHelper.FindParentObject <GalleryItemControl>(res.VisualHit);
         if (target != null && target.Item != dragableItem)
         {
             GalleryItemCollection targetCollection = target.Item.Group.Items;
             GalleryItemCollection sourceCollection = dragableItem.Group.Items;
             int targetIndex = targetCollection.IndexOf(target.Item);
             if (targetCollection == sourceCollection)
             {
                 targetCollection.Move(originalIndex, targetIndex);
             }
             else
             {
                 sourceCollection.Remove(dragableItem);
                 targetCollection.Insert(targetIndex, dragableItem);
             }
             dragableItem = null;
         }
     }
 }