No support for derived item container classes
punker76 opened this issue · 1 comments
punker76 commented
Original author: Jan_Waec...@gmx.de (January 16, 2011 15:53:40)
I have a ListBox which uses a custom item container class (derived from ListBoxItem). After enabling drag and drop for this ListBox (using dd:DragSource = "true" dd:DropTarget = "true") selecting any item was not possible anymore.
The problem is caused by, GetItemContainer not finding my custom derived item container class.
I'd recommend changing GetVisualAncestor not to use "==" for type checking, but using something which is comparable to the "is" operator:
public static DependencyObject GetVisualAncestor(this DependencyObject d, Type type)
{
DependencyObject item = VisualTreeHelper.GetParent(d);
while (item != null)
{
if (item.GetType() == type ||
item.GetType().IsSubclassOf(type))
return item;
item = VisualTreeHelper.GetParent(item);
}
return null;
}
After this change the problem is gone.
Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=30
punker76 commented
will be supported in 0.1.3.9