
{"id":921,"date":"2012-02-10T13:45:33","date_gmt":"2012-02-10T18:45:33","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=921"},"modified":"2012-02-10T13:45:33","modified_gmt":"2012-02-10T18:45:33","slug":"wpf-default-style-is-not-applied-when-its-the-only-app-resource","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=921","title":{"rendered":"WPF: Default style is not applied when it&#039;s the only app resource"},"content":{"rendered":"<p>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:<\/p>\n<p>1. The style is the only application resource in <code>app.xaml<\/code>.<br \/>\n2. The application main window is created manually and not via <code>StartupUri<\/code> attribute.<\/p>\n<p>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 <code>StartupUri<\/code> attribute.<\/p>\n<p>Example code is here: <a href=\"http:\/\/www.ikriv.com\/en\/prog\/info\/dotnet\/DefaultStyleSingleResource.zip\">DefaultStyleSingleResource.zip<\/a>.<br \/>\n<a style=\"display:none\" href=\"http:\/\/www.codeproject.com\/script\/Articles\/BlogFeedList.aspx?amid=1181663\" rel=\"tag\">CodeProject<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 <a href=\"https:\/\/ikriv.com\/blog\/?p=921\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[4,12],"tags":[],"class_list":["entry","author-ikriv","post-921","post","type-post","status-publish","format-standard","category-hack","category-wpf"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=921"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/921\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}