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

Drag action gets incorrect item object type in ItemsControl collection #477

Open
I4-PJ opened this issue Nov 1, 2023 · 2 comments
Open
Labels

Comments

@I4-PJ
Copy link

I4-PJ commented Nov 1, 2023

Describe the bug
When using ItemsControl with variety of item underlying types, the drag behaves incorrectly. The item type is evaluated incorrectly, thus drag won't work.

To Reproduce
Steps to reproduce the behavior:
Make ItemsSource element with binding to collection allowing different class types in that collection
Add those different class type items to the collection

Expected behavior
Drag action gets underlying collection type accordingly

Snímek obrazovky 2023-11-01 164255

The issue seems at ItemsControlExtensions.cs and its
public static Type GetItemContainerType(this ItemsControl itemsControl, out bool isItemContainer, DependencyObject child) method
when item type is not identified correctly

I did a small workaround without larger method change:

Added new method to find appropriate item index by any item in VisualTree and changed slightly a process handling ItemsSource object.
ItemsControlExtensions.zip

@I4-PJ I4-PJ added the Bug label Nov 1, 2023
@punker76
Copy link
Owner

punker76 commented Nov 1, 2023

@I4-PJ Can you maybe provide a full sample for this as repo on GitHub?

@I4-PJ
Copy link
Author

I4-PJ commented Nov 4, 2023

See attached a simple project. When added red and green items, drag works incorrectly.
WpfApp1.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants