HitTestFilterBehavior 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定點擊測試篩選回呼方法中點擊測試的傳回行為。
public enum class HitTestFilterBehavior
public enum HitTestFilterBehavior
type HitTestFilterBehavior =
Public Enum HitTestFilterBehavior
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| ContinueSkipSelfAndChildren | 0 | 不要與當前或 Visual 其後代進行測試。 |
| ContinueSkipChildren | 2 | 對當前 Visual的 ,但不對其後代進行測試。 |
| ContinueSkipSelf | 4 | 不要對當前的電流 Visual進行測試,而是對其後代進行測試。 |
| Continue | 6 | 對潮流 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為 ,你可以將當前視覺物件及其後代從命中測試結果評估中移除。
Note
修剪物件的視覺樹可減少命中測試結果評估通過時所需的處理量。
修剪視覺樹