From 3b7a45b58b163f210324197eec432d4a7f18be0e Mon Sep 17 00:00:00 2001 From: Lucas Trzesniewski Date: Thu, 11 Aug 2016 13:18:55 +0200 Subject: [PATCH] Use target root element to display adorners This allows to display adorners when the source and target elements are not part of the same root. --- GongSolutions.Wpf.DragDrop/DragDrop.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GongSolutions.Wpf.DragDrop/DragDrop.cs b/GongSolutions.Wpf.DragDrop/DragDrop.cs index b52dfd85..fcf29fca 100644 --- a/GongSolutions.Wpf.DragDrop/DragDrop.cs +++ b/GongSolutions.Wpf.DragDrop/DragDrop.cs @@ -432,7 +432,7 @@ private static void IsDropTargetChanged(DependencyObject d, DependencyPropertyCh } } - private static void CreateDragAdorner() + private static void CreateDragAdorner(DropInfo dropInfo) { var template = GetDragAdornerTemplate(m_DragInfo.VisualSource); var templateSelector = GetDragAdornerTemplateSelector(m_DragInfo.VisualSource); @@ -499,7 +499,7 @@ private static void CreateDragAdorner() adornment.Opacity = GetDefaultDragAdornerOpacity(m_DragInfo.VisualSource); } - var rootElement = RootElementFinder.FindRoot(m_DragInfo.VisualSource); + var rootElement = RootElementFinder.FindRoot(dropInfo.VisualTarget ?? m_DragInfo.VisualSource); DragAdorner = new DragAdorner(rootElement, adornment); } } @@ -542,7 +542,7 @@ private static void CreateEffectAdorner(DropInfo dropInfo) var template = GetEffectAdornerTemplate(m_DragInfo.VisualSource, dropInfo.Effects, dropInfo.DestinationText); if (template != null) { - var rootElement = RootElementFinder.FindRoot(m_DragInfo.VisualSource); + var rootElement = RootElementFinder.FindRoot(dropInfo.VisualTarget ?? m_DragInfo.VisualSource); var adornment = new ContentPresenter(); adornment.Content = m_DragInfo.Data; @@ -869,7 +869,7 @@ private static void DropTarget_PreviewDragOver(object sender, DragEventArgs e) dropHandler.DragOver(dropInfo); if (DragAdorner == null && m_DragInfo != null) { - CreateDragAdorner(); + CreateDragAdorner(dropInfo); } if (DragAdorner != null) {