I want to drop something not on the whole ListBox, but on a specific ListBoxItem. I'm handling the ListBox' Drop event - how can I find out, on which item the mouse is pointing?
A:
You can use VisualTreeHelper.HitTest
to figure out which ListViewItem is at the given point. That said, there may well be an easier way to do what you require, but there's not really enough info to go on.
HTH, Kent
Kent Boogaart
2009-10-20 19:33:45
I tried this code:if (e.Data.GetDataPresent(typeof(Songs))) { var result = VisualTreeHelper.HitTest(this.Playlists, Mouse.GetPosition(this.Playlists)); (in the Drop-handler) but it always returns null!
eWolf
2009-10-20 19:54:23
A:
if (e.Data.GetDataPresent(typeof(Songs)))
{
var result = VisualTreeHelper.HitTest(myCanvas, Mouse.GetPosition(this.Playlists));
}
If using a canvas, try performing your hittest relative to the Canvas (replace "myCanvas" with the reference)
Gurdas Nijor
2009-10-20 21:19:34