命中测试...是否可以测试列表框或其他项目控件中的项目
我试图点击列表框中的测试项目但无济于事。是否可以? VisualTreeHelper 显示 x,y 坐标,其中每个项目都返回 0,0,其中似乎排除了命中测试。有谁知道解决方案或解决方法?
I'm trying to hit test items within a listbox but to no avail. Is it possible? The VisualTreeHelper shows the x,y coordinates returning 0,0 for each and every item within which would seem to rule hit testing out. Does anyone know of a solution or workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你尝试过什么?您是否尝试过
UIElement.InputHitTest
方法?
VisualTreeHelper.HitTest
方法?您是否已通读本文?根据您的问题,我猜您正在致电
VisualTreeHelper.GetOffset
?如果是这样,则偏移量是相对于父级的,很可能是 0,0。您需要向我们提供更多信息来帮助您。
What have you tried? Have you tried the
UIElement.InputHitTest
method? TheVisualTreeHelper.HitTest
method? Have you read through this?Based on your question I guess you're calling
VisualTreeHelper.GetOffset
? If so, the offset is relative to the parent, which may very well be 0,0.You need to give us more information with which to help you.
试试这个:
假设
listbox1.SelectionMode
设置为SelectionMode.One
(这是默认设置)。Try this:
This assumes that
listbox1.SelectionMode
is set toSelectionMode.One
(which is the default setting).