Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for derived item container classes #30

Closed
punker76 opened this issue Feb 18, 2013 · 1 comment
Closed

No support for derived item container classes #30

punker76 opened this issue Feb 18, 2013 · 1 comment

Comments

@punker76
Copy link
Owner

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 added a commit that referenced this issue Aug 7, 2013
add support for derived item container classes
@punker76
Copy link
Owner Author

punker76 commented Aug 7, 2013

will be supported in 0.1.3.9

@punker76 punker76 closed this as completed Aug 7, 2013
punker76 added a commit that referenced this issue Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant