HitTestFilterBehavior 列舉

定義

在點擊測試篩選回呼方法中指定的點擊測試傳回行為。Specifies the return behavior of a hit test in a hit test filter callback method.

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

欄位

Continue 6

針對目前 Visual 和其子系的點擊測試。Hit test against the current Visual and its descendants.

ContinueSkipChildren 2

對目前的 Visual (但排除其子代) 進行點擊測試。Hit test against the current Visual, but not its descendants.

ContinueSkipSelf 4

不要對目前的 Visual 進行點擊測試,但要對其子代進行點擊測試。Do not hit test against the current Visual, but hit test against its descendants.

ContinueSkipSelfAndChildren 0

不要對目前的 Visual 或其子代進行點擊測試。Do not hit test against the current Visual or its descendants.

Stop 8

停止目前 Visual 的點擊測試。Stop hit testing at the current Visual.

範例

下列範例顯示如何 HitTestFilterBehavior 從點擊測試篩選回呼方法傳回值。The following example shows how to return a HitTestFilterBehavior value from a hit test filter callback method. 在此情況下,篩選會略過標籤及其下階,並點擊測試其他所有專案。In this case, the filter skips labels and their descendants and hit tests everything else.

// 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 ,它會決定處理視覺化樹狀結構進行點擊測試時,應採取何種類型的動作。The return value of the hit test filter callback is a HitTestFilterBehavior, which determines what type of action should be taken when processing the visual tree for hit testing. 例如,如果您的點擊測試篩選回呼傳回值 ContinueSkipSelfAndChildren ,您可以從點擊測試結果評估中移除目前的視覺物件和其子系。For example, if your hit test filter callback returns the value ContinueSkipSelfAndChildren, you can remove the current visual object and its descendants from the hit test results evaluation.

注意

剪除物件的視覺化樹狀結構會減少在點擊測試結果評估階段期間所需的處理量。Pruning the visual tree of objects decreases the amount of processing that is required during the hit test results evaluation pass.

使用點擊測試篩選剪除視覺化樹狀Pruning a visual tree using a hit test filter
剪除視覺化樹狀結構Pruning a visual tree

適用於