I use the IsMouseOver
property frequently in my WPF program. Unfortunately, I have other visual elements from other branches of the visual tree that sometimes cover up my controls. When they cover up my controls, the IsMouseOver
becomes false on my controls, even when my mouse is over the covered up control.
How can my control have a property like IsMouseOver
that doesn't care if it's covered up at the cursor location? Like a hit test that can tunnel threw covers.
I looked at this solution but I don't think I can use it, because it basically uses polling every time that the mouse moves. I think that would slow down my program significantly, because my visual tree is extensive.
Note that the visual elements that cover up my controls are not children of my controls.
Edit: Setting IsHitTestVisible
to false on the element that is doing the covering would be a very nice solution, but when I do that then the covering element doesn't interact with the mouse at all. I need both the covered and the covering elements to react to the mouse.
Make the covering control invisible to Hit Testing by setting
IsHitTestVisible="False"