WPF: Default style is not applied when it's the only app resource

I encountered something that looks like a weird WPF bug. Default style will not be applied to controls if both of following conditions are true:

1. The style is the only application resource in app.xaml.
2. The application main window is created manually and not via StartupUri attribute.

If you add any other resource before or after the style, it works. If you put the style in window resources, it works. The bug occurs for both .NET 3.5 and .NET 4. It does not occur for Silverlight, in particular because it lacks the StartupUri attribute.

Example code is here: DefaultStyleSingleResource.zip.

Leave a Reply

Your email address will not be published. Required fields are marked *