// Return the result of the hit test to the callback.
public HitTestResultBehavior MyHitTestResult(HitTestResult result)
{
// Add the hit test result to the list that will be processed after the enumeration.
hitResultsList.Add(result.VisualHit);
// Set the behavior to return visuals at all z-order levels.
return HitTestResultBehavior.Continue;
}
3 回答
从“WPF Unleashed”,第383页:
这种回调的签名是
并且它必须返回
HitTestResultBehaviour.Continue
以接收进一步的命中,如下所示(来自MSDN上的链接页面):有关详细信息,请参阅MSDN documentation for VisualTreeHelper.HitTest .
您还可以尝试使用Mouse.DirectlyOver属性来获取鼠标下最顶层的元素 .
你能用VisualTreeHelper.HitTest吗?
http://lukieb.blogspot.com/2008/07/visualtreehelperhittest.html