diff --git a/GongSolutions.Wpf.DragDrop/DragDrop.cs b/GongSolutions.Wpf.DragDrop/DragDrop.cs index 12954953..b7ffe6f9 100644 --- a/GongSolutions.Wpf.DragDrop/DragDrop.cs +++ b/GongSolutions.Wpf.DragDrop/DragDrop.cs @@ -703,8 +703,14 @@ private static void DropTarget_PreviewDragOver(object sender, DragEventArgs e) if (m_DragInfo != null) { // move the adorner - _adornerPos.Offset(_adornerSize.Width * -GetDragMouseAnchorPoint(m_DragInfo.VisualSource).X, - _adornerSize.Height * -GetDragMouseAnchorPoint(m_DragInfo.VisualSource).Y); + var offsetX = _adornerSize.Width * -GetDragMouseAnchorPoint(m_DragInfo.VisualSource).X; + var offsetY = _adornerSize.Height * -GetDragMouseAnchorPoint(m_DragInfo.VisualSource).Y; + _adornerPos.Offset(offsetX, offsetY); + var maxAdornerPosX = DragAdorner.AdornedElement.RenderSize.Width; + var adornerPosRightX = (_adornerPos.X + _adornerSize.Width); + if (adornerPosRightX > maxAdornerPosX) { + _adornerPos.Offset(-adornerPosRightX + maxAdornerPosX, 0); + } } DragAdorner.MousePosition = _adornerPos;