Does the GroupBox Header in WPF swallow mouse-clicks?

后端 未结 4 1255
抹茶落季
抹茶落季 2020-12-23 16:41

Have a look at this very simple example WPF program:



        
4条回答
  •  生来不讨喜
    2020-12-23 17:10

    It appears to be a subtle bug in the control template for the GroupBox. I found by editing the default template for the GroupBox and moving the Border named 'Header' to the last item in the control templates Grid element, the issue resolves itself.

    The reason is that the one of the other Border elements with a TemplateBinding of BorderBrush was further down in the visual tree and was capturing the mouse click, that's why setting the BorderBrush to null allowed the CheckBox to correctly receive the mouse click.

    Below is resulting style for the GroupBox. It is nearly identical to the default template for the control, except for the Border element named 'Header', which is now the last child of the Grid, rather than the second.

    
    
    
    

提交回复
热议问题