Create a fully transparent WPF window to capture mouse events

前端 未结 6 2165
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 08:30

I\'m trying to trap mouse events in WPF by using a topmost, transparent non-modal window. I\'m finding that this works fine if the opacity of the window is 0.01 or greater

6条回答
  •  长情又很酷
    2020-12-29 09:25

    Setting the opacity to 100% (or any non-zero value), and the background to Transparent (instead of null) should make most controls hittable.

    Make sure to set IsHitTestVisible to true. Not all controls can be hit, even if the opacity is 100% and the background is transparent.

提交回复
热议问题