开发者

Why does my WPF GroupBox looks so weird?

开发者 https://www.devze.com 2023-01-18 12:27 出处:网络
I ha开发者_JAVA百科ve no style set anywhere in my application! UPDATE: This behavior appears to be the default, at least under Windows 7, according to this thread.

I ha开发者_JAVA百科ve no style set anywhere in my application!

Why does my WPF GroupBox looks so weird?

UPDATE:

Why does my WPF GroupBox looks so weird?


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. :))

0

精彩评论

暂无评论...
验证码 换一张
取 消