none
WPF ComboBox 展开之后,如何实现鼠标移出后自动收起ComboBox Item? RRS feed

  • 问题

  • 尝试直接设置ComboBox的MouseLeave 事件,发现鼠标移出时并不触发;

    然后在别的控件的Mouse Enter中设置相关属性,发现也不触发。

    可能ComboBox捕获鼠标移至为true,导致那些基于Mouse位移的事件都不触发。

    那么,如何才能实现在鼠标移出后自动收起ComboBox Item?

    2018年4月16日 2:02

全部回复

  • 你好,

    可以使用 IsMouseDirectlyOverChanged 来实现。

    private void ComboBox_IsMouseDirectlyOverChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
                if (combo1.IsDropDownOpen == true)
                {
                    combo1.IsDropDownOpen = false;
                }
     }

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2018年4月16日 8:07