HitTestResultBehavior 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷是否要在點擊測試期間繼續列舉任何剩餘的視覺物件。
public enum class HitTestResultBehavior
public enum HitTestResultBehavior
type HitTestResultBehavior =
Public Enum HitTestResultBehavior
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| Stop | 0 | 停止任何進一步的命中測試,並從回撥回程返回。 |
| Continue | 1 | 繼續對視覺樹階層中的下一個視覺進行測試。 |
範例
以下範例說明如何從命中測試結果回調方法回傳 HitTestResultBehavior 一個值。
// Return the result of the hit test to the callback.
public HitTestResultBehavior MyHitTestResult(HitTestResult result)
{
// Add the hit test result to the list that will be processed after the enumeration.
hitResultsList.Add(result.VisualHit);
// Set the behavior to return visuals at all z-order levels.
return HitTestResultBehavior.Continue;
}
' Return the result of the hit test to the callback.
Public Function MyHitTestResult(ByVal result As HitTestResult) As HitTestResultBehavior
' Add the hit test result to the list that will be processed after the enumeration.
hitResultsList.Add(result.VisualHit)
' Set the behavior to return visuals at all z-order levels.
Return HitTestResultBehavior.Continue
End Function
備註
命中測試結果回調方法定義了當視覺樹中特定視覺物件被識別出命中測試時,你所執行的動作。 執行完動作後,你會回傳一個 HitTestResultBehavior 值,決定是否繼續列舉其他視覺物件。
視覺化樹狀結構中的幾何只要包含指定座標值,您就可以列舉所有視覺物件。 透過回傳 Continue 你的命中測試回調方法,你可以辨識所有被擊中的視覺物件,即使是那些可能被其他視覺物件部分或完全遮蔽的物件。