Hi I have the following code, the filter call back gets called but the result call back doesn't, I've been looking at this for some time, any help would be appreciated.
public HitTestFilterBehavior MyHitTestFilter(DependencyObject o)
{
s += o.ToString() + " ";
//Test for the object value you want to filter.
if (o.GetType() != typeof(Node))
{
// Visual object and descendants are NOT part of hit test results enumeration.
return HitTestFilterBehavior.ContinueSkipSelf;
}
else
{
s+="node detected ";
// Visual object is part of hit test results enumeration.
return HitTestFilterBehavior.Continue;
}
}
Here is the code for the result callback:
public HitTestResultBehavior MyHitTestResult(HitTestResult result)
{
s += "in result callback ";
if (result.VisualHit.GetType() == typeof(Node))
{
hitResultsList.Add(result.VisualHit as Node);
s+= "node detected in result callback "
return HitTestResultBehavior.Stop;
}
return HitTestResultBehavior.Continue;
}
Here is how i am a calling the hit test:
hitResultsList.Clear();
VisualTreeHelper.HitTest(designerCanvas, new HitTestFilterCallback(MyHitTestFilter), new HitTestResultCallback(MyHitTestResult), new PointHitTestParameters(End));
Now, the filter callback is going through all the elements and finds the node, however the result callback doesn't get called at all.