private static void DragSource_Drop(object sender, DragEventArgs e) { if (DrgInfo.DragIcon == DragInfo.eDragIcon.Add || DrgInfo.DragIcon == DragInfo.eDragIcon.Move || DrgInfo.DragIcon == DragInfo.eDragIcon.MultiAdd) { try { if (sender is UcListView) { _DroppedPoint = e.GetPosition(sender as UcListView); } if (sender is Ginger.ucGrid) { _DroppedPoint = e.GetPosition(sender as Ginger.ucGrid); } object droppedItem = DrgInfo.Data; if (droppedItem is ObservableList <RepositoryItemBase> ) { ObservableList <RepositoryItemBase> repoItemsList = droppedItem as ObservableList <RepositoryItemBase>; if (repoItemsList != null && repoItemsList.Count > 0) { foreach (RepositoryItemBase listItem in repoItemsList) { DragInfo newDragInfo = new DragInfo() { DragIcon = DrgInfo.DragIcon, DragSource = DrgInfo.DragSource, DragTarget = DrgInfo.DragTarget, Header = DrgInfo.Header, OriginalSource = DrgInfo.OriginalSource, Data = listItem }; ((IDragDrop)DrgInfo.DragTarget).Drop(newDragInfo); } } } else { ((IDragDrop)DrgInfo.DragTarget).Drop(DrgInfo); } } catch (Exception ex) { ResetDragDrop(); } } }
public static void DragSource_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && !IsDragging) { Point position = e.GetPosition(null); if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { DrgInfo = new DragInfo(); DrgInfo.OriginalSource = e.OriginalSource; ((IDragDrop)sender).StartDrag(DrgInfo); // We start drag only of control put data in the drag data if (DrgInfo.Data != null) { StartDrag(e); } } } }