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); } } }
void AssociatedObject_DragEnter(object sender, DragEventArgs e) { if (this.dataType == null) { if (this.AssociatedObject.DataContext != null) { ICardDropable dropObject = this.AssociatedObject.DataContext as ICardDropable; if (dropObject != null) { this.dataType = dropObject.Type; } } } if (this.adorner == null) { this.adorner = new DragDropAdorner(sender as UIElement, e.GetPosition(sender as UIElement)); } e.Handled = true; }