HitTestFilterBehavior 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定命中测试筛选器回调方法中命中测试的返回行为。
public enum class HitTestFilterBehavior
public enum HitTestFilterBehavior
type HitTestFilterBehavior =
Public Enum HitTestFilterBehavior
- 继承
字段
| 名称 | 值 | 说明 |
|---|---|---|
| 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
修剪对象的可视化树可以减少命中测试结果评估通过期间所需的处理量。
修剪可视化树