閱讀英文

共用方式為


HitTestFilterBehavior 列舉

定義

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

C#
public enum HitTestFilterBehavior
繼承
HitTestFilterBehavior

欄位

名稱 Description
Continue 6

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

ContinueSkipChildren 2

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

ContinueSkipSelf 4

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

ContinueSkipSelfAndChildren 0

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

Stop 8

停止目前 Visual 的點擊測試。

範例

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

C#
// 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;
    }
}

備註

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

注意

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

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

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9