WPF: Get application mouse events without capture?

I want to make a user control like this:

If the TextBox gets focus, a PopUp is shown; if the TextBox loses focus, the PopUp is hided. That's not difficult. However, here is another requirement:

If the user click (mouse down) on the other areas/elements(Neither on the TextBox nor the PopUp) of this window, the PopUp is supposed to hide. (Notice: the focus is still on the TextBox)


And there are many reasons not to capture the mouse for the TextBox, the most important one is the TextBox has its own mechanism to handle the mouse event. Capturing the mouse may make the TextBox behaviours odd.

I am wondering if there is a method to get the application mouse events without capture the mouse?

I think there must be, think about the ComboBox, you know what I mean.

原文地址:https://www.cnblogs.com/guogangj/p/2852500.html