WPF ComboBox: click outside of popup suppress mouse click

前端 未结 3 1612
[愿得一人]
[愿得一人] 2021-01-21 17:15

I use a standard WPF ComboBox control. When popup is opened and user clicks somewhere outside, popup is closed. But if there is button on the window and user clicks on it (with

3条回答
  •  时光说笑
    2021-01-21 17:58

    You can try to release the mouse capture right after the ComboBox gets one: In your's ComboBox properties in XAML:

    GotMouseCapture="ComboBox_OnGotMouseCapture"
    

    And in code-behind:

    private void ComboBox_OnGotMouseCapture(object sender, MouseEventArgs e)
    {
        ComboBox.ReleaseMouseCapture();
    }
    

提交回复
热议问题