Reputation: 4516
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!
Upvotes: 2
Views: 382
Reputation: 5927
using Background or Fill = "{x:Null}" which is the default for some classes like Grid is not the same as Background or Fill = "Transparent". Setting Transparent as the background/fill color should work.
Upvotes: 1
Reputation: 11252
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.
Upvotes: 4