views:

231

answers:

1

Hi guys,

I am creating a custom control which does hit testing on its children. I'm planning on overriding the HitTestCore method to return multiple controls which fall inside or intersects with a Geometric region. Just wondering if anyone else has tried this. Do you have any pointers for me? Or is there another way which I can do this (without actually overriding the HitTestCore method)? Thanks in advance for any help. :)

A: 

So, I was able to get multiple controls seems like I didn't need to override the HitTestCore method.

I created a HitTestFilterCallback and whenever it hit on a CheckBox (which was the type of control I was hit testing) I saved it onto a list called _hitTestResults. But I'm not sure whether this is the right way to do this :S

Here is what I did:

HitTestFilterBehavior OnHitTestFilter(DependencyObject target)
    {
        if (target.GetType() == typeof(CheckBox))
        {
            _hitTestResults.Add(target as CheckBox); // add the hittest result
            return HitTestFilterBehavior.ContinueSkipChildren;
        }
        else
            return HitTestFilterBehavior.Continue;

    }
Nilu