HitTestResult.VisualHit 属性

定义

获取命中的视觉对象。

public:
 property System::Windows::DependencyObject ^ VisualHit { System::Windows::DependencyObject ^ get(); };
public System.Windows.DependencyObject VisualHit { get; }
member this.VisualHit : System.Windows.DependencyObject
Public ReadOnly Property VisualHit As DependencyObject

属性值

DependencyObject

一个 DependencyObject 值,该值表示命中的视觉对象。

示例

以下示例演示如何在命中测试回调方法中检索 VisualHit 属性值。

// 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;
}
' Return the result of the hit test to the callback.
Public Function MyHitTestResult(ByVal result As HitTestResult) As HitTestResultBehavior
    ' 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
End Function

注解

DependencyObject 是类型,而不是 Visual 使命中测试可以通过视区桥接 2D 和 3D 树。

适用于