punker76 / gong-wpf-dragdrop

The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ItemsControlExtensions.GetClosest leads to a crash if an item in items is not an item of the itemsControl

haukepribnow opened this issue · comments

ItemsControlExtensions.GetClosest contains this code:

  foreach (var i in items) {
    var uiElement = i as UIElement;

    if (uiElement != null) {
      var p = uiElement.TransformToAncestor(itemsControl).Transform(new Point(0, 0));

However, in some situations, the item i might not be a child of the itemsControl (for example when nesting ListBoxes containing draggable entries). In such a case, I got a InvalidOperationException from TransformToAncestor (with the German message "Das angegebene Visual-Objekt ist kein übergeordnetes Element dieses Visual-Objekts." which translates to: "The given Visual object is no ancestor of this Visual object.")

Therefore a fix should be implemented that makes sure that i is in fact a child of itemsControl.

@haukepribnow This should be fixed with f877268