Mouse event event

I have WPF control1 (there is a motion control) that is hosted via elementhost in the form of a window. My goal is to capture mouse move events for elementhost.

I learned from the following link that MouseMove fires when the control moves under the mouse, when the mouse is stationary.

http://social.msdn.microsoft.com/Forums/en/wpf/thread/56e7b331-ac6f-4d62-a83b-c09009b79fa0

I get fake mouse move events for elementhost. To fix this problem, I added a button on top of elementhost and set its Visible property to Hidden. However, I get fake mouse movement events. How to solve this problem? Is there a workaround?

Appreciate your help ...

+3
source share
2 answers

In your mousemove event, write the eX and eY values ​​while holding your mouse motionless. If they match, the problem is resolved.

+3
source

I just noticed this problem in a WPF application without ElementHost - mousemove always fires for a fixed mouse! Now I put an intermediate class between the publisher and the subscriber to filter events if duplication of X and Y points occurs (plus disconnect subscribers from MouseEventArgs so that I can unit test subscribers)

0
source

Source: https://habr.com/ru/post/1740710/


All Articles