共用方式為


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 樹狀結構。

適用於