haithambradai / gong-wpf-dragdrop

Automatically exported from code.google.com/p/gong-wpf-dragdrop
0 stars 0 forks source link

CreateDragAdorner doesn't use correct rootElement #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by sportfr...@gmail.com on 4 May 2010 at 2:56

GoogleCodeExporter commented 9 years ago
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?

Original comment by gro...@gmail.com on 4 May 2010 at 4:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Applied to trunk in r20.

Original comment by gro...@gmail.com on 4 May 2010 at 4:45

GoogleCodeExporter commented 9 years ago
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). 

Original comment by sportfr...@gmail.com on 4 May 2010 at 4:46

GoogleCodeExporter commented 9 years ago
Issue 23 has been merged into this issue.

Original comment by gro...@gmail.com on 4 Jul 2010 at 11:09