开发者

WPF: Why would this cause a stack overflow exception?

When I add this style, it breaks my application with a StackOverflowException.

<Style Targe开发者_运维技巧tType="GroupBox" BasedOn="{StaticResource {x:Type GroupBox}}" >
<!-- <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" /> -->
</Style>

In case it matters, I'm using the ShinyBlue theme.

Any ideas what would cause this?


That's kind of a "known issue", at least I remember I had it too and it reproduces with styles based on default styles for controls which also have some default styles in the theme. AFAIR, I used my own theme, so I just went and gave names to those styles and used the names instead of the {x:Type GroupBox} and it helped me, but if you can't do this, the Internets advise you to move your derived styles to a lower XAML scope.

As for the root cause of the exception, AFAIR, there is a bug in the default style resolution, which takes theme's style as the default for your custom style and then takes your custom style as the default for the theme's one and so on, so forth, SO!


Try changing the name of your static resource.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜