punker76/gong-wpf-dragdrop

Highlight adorner outlines too much when TreeView item is collapsed

punker76 opened this issue · 2 comments

Original author: neilboyd (October 11, 2011 15:12:39)

What steps will reproduce the problem?

  1. Change the DefaultDropHandler to use DropTargetAdorners.Highlight instead of DropTargetAdorners.Insert (an easy way to demonstrate the issue)
  2. Run the DefaultsExample
  3. Select the Bound TreeViews tab
  4. Expand Root1
  5. Collapse Root1
  6. Expand Root2
  7. Drag Item10 over Root1

What is the expected output? What do you see instead?
You will see that the highlight outline covers the space that Root1 did have when it was expanded.
It should only cover the now collapsed space.

What version of the product are you using? On what operating system?
Revision 38. Windows XP.

Please provide any additional information below.
Patch to fix it is attached.

Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=39

Index: GongSolutions.Wpf.DragDrop/DropTargetHighlightAdorner.cs
===================================================================
--- GongSolutions.Wpf.DragDrop/DropTargetHighlightAdorner.cs    (revision 38)
+++ GongSolutions.Wpf.DragDrop/DropTargetHighlightAdorner.cs    (working copy)
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
+using System.Windows;
 using System.Windows.Media;

 namespace GongSolutions.Wpf.DragDrop
@@ -13,14 +9,14 @@
             : base(adornedElement)
         {
         }
-        
+
         protected override void OnRender(DrawingContext drawingContext)
         {
             if (DropInfo.VisualTargetItem != null)
             {
                 Rect rect = new Rect(
                     DropInfo.VisualTargetItem.TranslatePoint(new Point(), AdornedElement),
-                    VisualTreeHelper.GetDescendantBounds(DropInfo.VisualTargetItem).Size);
+                    DropInfo.VisualTargetItem.DesiredSize);
                 drawingContext.DrawRoundedRectangle(null, new Pen(Brushes.Gray, 2), rect, 2, 2);
             }
         }

fixed in version 0.1.3.6