-
-
Notifications
You must be signed in to change notification settings - Fork 405
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
Add logic to disallow child items in tree views #453
base: develop
Are you sure you want to change the base?
Conversation
This solves this exact issue I was having. But I may have found an issue. When using this change, on the drop handler, dropInfo.TargetItem will still reference the model that didn't allow for the drop and not the model where the source was eventually dropped (usually its parent). Can you confirm this is happening? And is it by design for some reason? |
Here's some more info on this with a couple of screenshots: Note the cursor's position on top of the "Calculator" item even though the drop indicator shows that it will be dropped as a sibling (inside "Example sub-folder"). Again, almost the same as above but note the cursor's position on top of "CMD". Hope this helps, cheers. |
I sent this PR a while ago, but I believe this is by design. The code in the demo uses if (dropInfo is DropInfo { TargetItem: not TreeNode { Icon: PackIconMaterialKind.Folder } } typedDropInfo)
typedDropInfo.AcceptChildItem = false; It wouldn't feel right for Also, |
Hey, thanks for replying. That's fine if it's by design and it's working great for the dropover event. The issue I see is that on the drop event (which is where we would eventually do any needed model updates or any extra work after the drop is completed) there is apparently no direct reference on the dropInfo parameter to where the drag source was actually eventually dropped when using So if we then follow something like the drop event example on the documentation, that But I get what you said, it's not really the wrong target. It's the correct target the mouse was over when it dropped, but just not the target where the object was eventually dropped, since it had Thanks again for this PR and for replying 👍 |
Yes, I agree this would be useful, but the API this PR currently provides doesn't make that easy, as Maybe changing the I'd like some input from @punker76 before I make this change though. |
Though, it seems the current library design may make it necessary to keep the |
No problem of course. Thanks anyway for tackling this issue in the first place. The dropover behavior this PR adds and the In the meantime I'll probably just actually add some sort of RealTargetItem/FinalTargetItem property on my local copy since, like you, I was already pondering it as the quickest fix for my case, even if it may not be ideal for this project as a final solution. Thanks again, cheers 👍 |
Any news on that? I encounter the same problem solved by this PR. |
Any updates on this? |
Sorry if it looks like I'm ignoring it. But it's not like that. It's on my TODO list. |
What changed?
This fixes #344, in a different way than #345.
I wanted to fix this issue, but I felt it's the role of the drop handler to decide whether an item should accept children or not (instead of handling this through a dependency property of the item). This also enables providing custom logic.
Problem is, at that point the
IDropInfo
is already populated with the "wrong"TargetCollection
/InsertIndex
info because everything is decided upfront in the constructor ofDropInfo
.I didn't want to introduce a breaking change, so this solution isn't ideal. Please tell me if this approach is OK or if you'd prefer something else.
This adds a new
AcceptChildItem
property inDropInfo
(specifically not inIDropInfo
in order to avoid the breaking change), which will recalculate the relevant properties when set tofalse
by the user.Here's the result:
/cc @jizc