punker76/gong-wpf-dragdrop

GetClosest method doesn't handle nested elements

faeriedust opened this issue · 3 comments

In the vertical search case, it condenses each of the "hits" above and below it into single points and finds the closest one to the position and returns that element.

However, this is not correct in the case that there are nested elements above/below it.

It should return the one with a nearest edge to the position at the very worst.

My example:
I have a ListView of Jobs where each ListViewItem is an inner ListView of Tasks.
If I click below the lowest Job, I would expect the FindClosest Method to be returning the lowest Job.
However, if there is a task inside that job, and directly above the clicked position, the Task will be returned instead because it is "lower" than the job that it's nested inside.

Possible fix is to take item size into account to find the nearest border and find the distance from that?

https://github.com/faeriedust/GongWPFDemo illustrates the bug in question

@faeriedust This should be fixed with f877268