3 回答

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊
從“ WPF釋放 ”,第383頁(yè):
視覺(jué)命中測(cè)試可以通知您所有 Visual與位置相交的信息,您必須使用[VisualTreeHelper.]HitTest接受HitTestResultCallback委托的 方法 。在此版本的HitTestreturn 之前Visual,從最高處開(kāi)始到最低處結(jié)束的每個(gè)相關(guān)調(diào)用一次委托。
這樣的回調(diào)的簽名是
HitTestResultBehavior Callback(HitTestResult result)
并且必須返回HitTestResultBehaviour.Continue以接收進(jìn)一步的匹配,如下所示(來(lái)自MSDN的鏈接頁(yè)面):
// 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;
}
有關(guān)更多信息,請(qǐng)查閱MSDN文檔VisualTreeHelper.HitTest。
- 3 回答
- 0 關(guān)注
- 705 瀏覽
添加回答
舉報(bào)