Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my WPF GroupBox looks so weird?

I have no style set anywhere in my application! alt text

UPDATE: alt text

like image 785
Elisabeth Avatar asked Sep 28 '10 20:09

Elisabeth


1 Answers

This behavior appears to be the default, at least under Windows 7, according to this thread.

It looks like the GroupBox border actually gets an additional white border both inside and outside: just try increasing the BorderThickness, and you'll see what I mean.

Also, compare to another control - a Label, for instance - and notice that when you define a border around that, even a rounded border, there's no white 'shadow'.

As far as I can tell, the only way around this (if you need one) is to define a ControlTemplate for the GroupBox yourself. The link posted above contains a good example: notice the answer that sets the BorderBrush on those surrounding Borders to Transparent.

The canonical example for that custom template can be found in the GroupBox MSDN documentation.

(On an unrelated note, that BorderGapMaskConverter in the example is interesting - that's how the GroupBox knows to render the part of the border beneath the header as transparent... Neat. :))

like image 118
Dan J Avatar answered Nov 13 '22 04:11

Dan J