Export to GitHub

gong-wpf-dragdrop - issue #11

CreateDragAdorner doesn't use correct rootElement


Posted on May 4, 2010 by Happy Hippo

When you start dragging and your window isn't the main one, the dragAdorner isn't shown.

Please change CreateDragAdorner into: static void CreateDragAdorner() { DataTemplate template = GetDragAdornerTemplate(m_DragInfo.VisualSource);

        if (template != null)
        {
            UIElement rootElement = null;
            // Find the current top window 
            Window parentWindow =

TryFindParent<Window>(m_DragInfo.VisualSource); if (parentWindow != null) rootElement = parentWindow.Content as UIElement; if (rootElement == null) rootElement = (UIElement)Application.Current.MainWindow.Content; UIElement adornment = null; ....

The TryFindParent method is well documented at http://www.hardcodet.net/2008/02/find-wpf-parent

Good luck,

Frank

Comment #1

Posted on May 4, 2010 by Helpful Kangaroo

Thanks for the report and the fix! Patch committed. I didn need TryFindParent - I have my own extension method GetVisualAncestor<> which does the same thing.

Could you check the patch indeed fixes the problem for you?

Comment #2

Posted on May 4, 2010 by Helpful Kangaroo

Comment deleted

Comment #3

Posted on May 4, 2010 by Helpful Kangaroo

Applied to trunk in r20.

Comment #4

Posted on May 4, 2010 by Happy Hippo

Ok, I will see it.

When you drag a root to a child you now get grandchildren. I'm yet altering your component to preserve the level in a TreeList (using the classes of the interfaces).

That might be something for the generic Component. A boolean called PreserveLevel that only allows starting a drag when all items have the same level and allow dropping when the target has that same level (or one higher).

Comment #5

Posted on Jul 4, 2010 by Helpful Kangaroo

Issue 23 has been merged into this issue.

Status: Fixed

Labels:
Type-Defect Priority-Medium