void AssociatedObject_DragLeave(object sender, DragEventArgs e) { if (this.adorner != null) { this.adorner = null; } e.Handled = true; }
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; }
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; } } }