PointHitTestResult.VisualHit 屬性

定義

取得從點擊測試結果傳回的視覺物件。

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

屬性值

Visual

代表點擊測試結果的 Visual 物件。

範例

下列範例示範如何在點擊測試結果回呼函式中存取 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

備註

VisualHit 可能會在單一點擊測試期間代表多個視覺物件。 點擊測試回呼方法定義您在視覺化樹狀結構中的特定視覺物件上,識別出點擊測試時執行的動作。 執行動作之後,您會傳回一個 HitTestResultBehavior 值,判斷是否要繼續列舉任何其他視覺物件。 傳回之視覺物件的列舉順序是依轉譯平面的圖層順序。

適用於