3 回答

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