ItemsControlExtensions.GetClosest leads to a crash if an item in items is not an item of the itemsControl
haukepribnow opened this issue · 1 comments
haukepribnow commented
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 ListBoxe
s 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
.
punker76 commented
@haukepribnow This should be fixed with f877268