本文介绍了VS 2017& VB.net - 我如何HitTest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在drop事件期间找到指针下面的特定ListViewItem(主要是作为一个思考练习,看看我以后是否能够聪明)。似乎在线的共识是我应该使用HitTest(VisualTreeHelper.HitTest)
来实现这一目标。但是,当我尝试使用创建HitTest的示例代码时,我得到了晃动的红线,错误"HitTest"不是"VisualTreeHelper"的成员。我已经尝试添加引用以找到难以捉摸的HitTest所在的位置,但是没有任何运气的
- 说实话,我发现的任何在线搜索结果都没有说过"不要忘记包含x / y / z以使其工作"。

I am trying to find the specific ListViewItem that is under the pointer during a drop event (mainly as a thought exercise to see if I can be clever at a later date). It seems that the consensus on-line is that I should be using a HitTest (VisualTreeHelper.HitTest) to achieve this. However, when I try and use the example code that creates a HitTest, I get wiggly red lines and the error 'HitTest' is not a member of 'VisualTreeHelper'. I've tried adding references to find where the elusive HitTest lives, but have not had any luck - and to be honest, none of the on-line search results I have found have said anything like "Don't forget to include x/y/z for this to work".

那么,请问,有人能告诉我在VS2017(VB.net)上的UWP中我能启用HitTesting吗? (此时我会接受"无法完成"作为答案!

So, please, can anyone tell me how in a UWP on VS2017 (VB.net) I can enable HitTesting? (I'll accept "Can't be done" as an answer at this point!

推荐答案

Welcome
开发通用Windows应用程序论坛
!请使用  标记 
发布到此论坛时,谢谢!


  1. 你能不能告诉我你在哪里找到示例代码?我搜索了
    VisualTreeHelper Class
    但没有找到hittest()函数。
  2. 但是您可以使用
    VisualTreeHelper.FindElementsInHostCoordinates()
     我在stacknbsp中找到了类似的问题; 。请参阅@Rob Caplan的答案,了解如何获取UIElements
    与特定坐标相交。 
  3. 对于可以使用命中测试的元素有一些要求。请参考  命中
    测试和输入事件
     了解有关要求的详细信息。
  1. Could you please tell me where you find the sample code? I searched theVisualTreeHelper Class but didn’t found the hittest() function.
  2. But you could detect the control under a point in UWP usingVisualTreeHelper.FindElementsInHostCoordinates().  I’ve found a similar question in stacknbsp;How can I detect the control under a point in uwp. Please refer @Rob Caplan’s answer for about how to get UIElements intersect a specific coordinate. 
  3. There are some requirements for the element which could use hit testing. Please refer Hit testing and input events for more details about the requirement.


注意:此响应包含对第三方万维网站点的引用.Microsoft
提供此信息是为了方便您.Microsoft不控制这些站点,也没有测试任何软件或信息在这些网站上发现;因此,Microsoft不能对其中发现的任何软件或信息的质量,安全性或适用性做出任何陈述。使用互联网上的任何软件都存在固有的危险,并且Microsoft警告在从互联网上检索任何软件之前,请确保您完全了解风险。

最好的问候,

Roy


这篇关于VS 2017& VB.net - 我如何HitTest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:03