【发布时间】:2012-04-17 15:50:56
【问题描述】:
我有一个 WPF ParentUserControl 和一些 ChildUserControlA ChildUserControlB 等(也是 WPF 控件)
ChildUserControls 是控件,其中包含一些其他基本元素(文本框、标签等)
在主窗体的状态栏中,我需要显示当前鼠标悬停的名称ChildUserControl。
因此,在 ParentUserControl 的 MouseMove 中,我获得了一个对象 myElement = Mouse.DirectlyOver,因为我需要最顶部的 ChildUserControl,但我获得了一个 'System .Windows.Controls.TextBlock'(ChildUserControl 的一部分)...
如何解决这个问题?
当我将鼠标悬停在 MyChildControl 上时,我需要检测到 MyChildControl,而不是它的子元素。
按此顺序,我在 MyChildControl 上使用了以下内容:
Protected Overrides Function HitTestCore(
hitTestParameters As PointHitTestParameters) As HitTestResult
Return New PointHitTestResult(Me, hitTestParameters.HitPoint)
End Function
但无论如何我有时会得到文本块,有时会得到 ChildUserControl...
【问题讨论】:
标签: .net wpf vb.net wpf-controls