Create a fully transparent WPF window to capture mouse events

前端 未结 6 2157
爱一瞬间的悲伤
爱一瞬间的悲伤 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:15

    You might find it simpler to use Mouse.Capture.

    https://msdn.microsoft.com/en-us/library/ms771301.aspx

    When an object captures the mouse, all mouse related events are treated as if the object with mouse capture perform the event, even if the mouse pointer is over another object.

提交回复
热议问题