I've got a custom control that inherits from FrameworkElement. It contains a Visual that contains transparent areas. I'm trying to make the entire control area respond to hit tests, but at the moment, when I click on part of the control that displays a transparent area of the Visual, the click passes through to the underlying layer.
Is there a way of making the entire control hit-testable without using a hack?
I'd like to stay away from techniques like painting the background of the Visual white, or adding a Border around the custom control that has the same event handler set.
Thanks in advance!
Simply use a transparent brush and it will respond to hit testing.
For example, if you have null background brush, then hit testing will pass right through.
If you use Brushes.Transparent as a background or fill area, then it will work with hit testing.