HitTestFilterBehavior 列舉

定義

在點擊測試篩選回呼方法中指定的點擊測試傳回行為。

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

欄位

Continue 6

針對目前 Visual 和其子系的點擊測試。

ContinueSkipChildren 2

對目前的 Visual (但排除其子代) 進行點擊測試。

ContinueSkipSelf 4

不要對目前的 Visual 進行點擊測試,但要對其子代進行點擊測試。

ContinueSkipSelfAndChildren 0

不要對目前的 Visual 或其子代進行點擊測試。

Stop 8

停止目前 Visual 的點擊測試。

範例

下列範例示範如何從點擊測試篩選回呼方法傳回 HitTestFilterBehavior 值。 在此情況下,篩選會略過標籤及其子系,並點擊測試所有其他專案。

// Filter the hit test values for each object in the enumeration.
public HitTestFilterBehavior MyHitTestFilter(DependencyObject o)
{
    // Test for the object value you want to filter.
    if (o.GetType() == typeof(Label))
    {
        // Visual object and descendants are NOT part of hit test results enumeration.
        return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
    }
    else
    {
        // Visual object is part of hit test results enumeration.
        return HitTestFilterBehavior.Continue;
    }
}
' Filter the hit test values for each object in the enumeration.
Public Function MyHitTestFilter(ByVal o As DependencyObject) As HitTestFilterBehavior
    ' Test for the object value you want to filter.
    If o.GetType() Is GetType(Label) Then
        ' Visual object and descendants are NOT part of hit test results enumeration.
        Return HitTestFilterBehavior.ContinueSkipSelfAndChildren
    Else
        ' Visual object is part of hit test results enumeration.
        Return HitTestFilterBehavior.Continue
    End If
End Function

備註

點擊測試篩選回呼的傳回值是 HitTestFilterBehavior ,決定在處理視覺化樹狀結構以進行點擊測試時應該採取的動作類型。 例如,如果您的點擊測試篩選回呼傳回值 ContinueSkipSelfAndChildren ,您可以從點擊測試結果評估中移除目前的視覺物件及其子代。

注意

剪除物件的視覺化樹狀結構會減少點擊測試結果評估通過期間所需的處理量。

使用點擊測試篩選來剪除視覺化樹狀結構使用
剪除視覺化樹狀結構

適用於