語言

HitTestResultBehavior 列舉

定義

判斷是否要在點擊測試期間繼續列舉任何剩餘的視覺物件。

public enum class HitTestResultBehavior
public enum HitTestResultBehavior
type HitTestResultBehavior = 
Public Enum HitTestResultBehavior
繼承
HitTestResultBehavior

欄位

名稱 值 Description
Stop 0

停止任何進一步的命中測試,並從回撥回程返回。

Continue 1

繼續對視覺樹階層中的下一個視覺進行測試。

範例

以下範例說明如何從命中測試結果回調方法回傳 HitTestResultBehavior 一個值。

// 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

備註

命中測試結果回調方法定義了當視覺樹中特定視覺物件被識別出命中測試時,你所執行的動作。 執行完動作後,你會回傳一個 HitTestResultBehavior 值,決定是否繼續列舉其他視覺物件。

視覺化樹狀結構中的幾何只要包含指定座標值,您就可以列舉所有視覺物件。 透過回傳 Continue 你的命中測試回調方法,你可以辨識所有被擊中的視覺物件,即使是那些可能被其他視覺物件部分或完全遮蔽的物件。

適用於

另請參閱