如何在 Silverlight ListBoxDragDropTarget 中查找拖放项目的索引位置
我有一个包含在 ListBoxDragDropTarget 中的 silverlight ListBox。我正在监听 DDT 的 Drop 事件,但我不知道如何找到 drop 操作的索引。即我想知道用户在哪个索引点将项目放入我的列表框中。在 UI 上,当我在 ListBox 上拖动时,我可以看到一条线指示我将鼠标悬停在其上的位置,但在放置后,我不知道如何从放置事件中获取放置位置信息。
I have a silverlight ListBox that is contained in a ListBoxDragDropTarget. I am listening to the Drop event of the DDT, but I don't know how to find the index of the drop action. i.e. I want to know at which index spot the user dropped the items into my ListBox. On the UI when I'm dragging over the ListBox, I can see a line indicating the spot that I'm hovering over, but after dropping, I don't know how to get the drop location information from the drop event.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给定以下 Xaml:
如果您想知道用户在其上放置项目的 ListBoxItem,您可以使用
e.GetPosition
获取鼠标的位置和VisualTreeHelper.FindElementsInHostCooperatives
对于命中测试:Given the following Xaml:
If you want to know the ListBoxItem on which the user dropped the items you can use
e.GetPosition
to get the position of the mouse andVisualTreeHelper.FindElementsInHostCoordinates
for hit testing: