static void DropTarget_PreviewDragEnter(object sender, DragEventArgs e) { if (!UpdateEffects(sender, e)) { return; } // Setup the preview Adorner var feedbackUI = GetDropTarget(sender as DependencyObject).GetVisualFeedback(e.Data); _offsetPoint = GetOffsetPoint(e.Data); var advisor = GetDropTarget(sender as DependencyObject); var mousePoint = MouseUtilities.GetMousePosition(advisor.TargetUI); //giving a tolerance of 2 so that the adorner is created when the mouse is moved fast. //this might still be small...in that case increase the tolerance if ((mousePoint.X < 2) || (mousePoint.Y < 2) || (mousePoint.X > ((FrameworkElement)(advisor.TargetUI)).ActualWidth - 2) || (mousePoint.Y > ((FrameworkElement)(advisor.TargetUI)).ActualHeight - 2) || (_overlayElt == null)) { CreatePreviewAdorner(sender as UIElement, feedbackUI); } e.Handled = true; }
static void DropTarget_PreviewDragLeave(object sender, DragEventArgs e) { if (UpdateEffects(sender, e) == false) { return; } var advisor = GetDropTarget(sender as DependencyObject); var mousePoint = MouseUtilities.GetMousePosition(advisor.TargetUI); //Console.WriteLine("Inside DropTarget_PreviewDragLeave1" + mousePoint.X.ToString() + "|" + mousePoint.Y.ToString()); //giving a tolerance of 2 so that the adorner is removed when the mouse is moved fast. //this might still be small...in that case increase the tolerance if ((mousePoint.X < 2) || (mousePoint.Y < 2) || (mousePoint.X > ((FrameworkElement)(advisor.TargetUI)).ActualWidth - 2) || (mousePoint.Y > ((FrameworkElement)(advisor.TargetUI)).ActualHeight - 2)) { RemovePreviewAdorner(); } e.Handled = true; }