void AssociatedObject_Drop(object sender, DragEventArgs e) { if (this.dataType != null) { if (e.Data.GetDataPresent(this.dataType)) { Card card = e.Data.GetData("Card") as Card; ICardDragable source = e.Data.GetData(this.dataType) as ICardDragable; source.RemoveDragCard(card); ICardDropable target = this.AssociatedObject.DataContext as ICardDropable; target.Drop(card); } } }
private void AssociatedObject_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (this.isLeftMouseDown) { ICardDragable dragingObject = this.AssociatedObject.DataContext as ICardDragable; if (dragingObject != null) { System.Diagnostics.Debug.WriteLine("mm"); this.adorner = new DragDropAdorner(this.AssociatedObject, e.MouseDevice.GetPosition(this.AssociatedObject)); var adornerLayer = AdornerLayer.GetAdornerLayer(this.AssociatedObject); adornerLayer.Add(this.adorner); this.AssociatedObject.Visibility = Visibility.Hidden; DataObject data = new DataObject(); data.SetData(dragingObject.Type, this.AssociatedObject.DataContext); data.SetData("Card", dragingObject.DragObject); System.Windows.DragDrop.DoDragDrop(this.AssociatedObject, data, DragDropEffects.Move); adornerLayer.Remove(adorner); this.AssociatedObject.Visibility = Visibility.Visible; } } }