Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:04:59+00:00 2026-05-14T15:04:59+00:00

I have just changed my WPF application from .Net3.5 to .Net4. Doing this caused

  • 0

I have just changed my WPF application from .Net3.5 to .Net4. Doing this caused all my global styles to stop working. Only the styles explicitly set using a key did work. I’ve done some research and figured out what causes this, and reproduced it in a simple app.

I have a simple WPF app containing only a button with text – no style or anything else. I define a style for all buttons in the ResourceDictionary of App.Xaml:

<Style TargetType="{x:Type Button}">
    <Setter Property="Background" Value="Red"></Setter>
</Style>

My button is now Red – all fine. I now move this to a separate ResourceDictionary in a separate project. This is where I want to hold all my shared styles. The button is still red, and my reference from App.xaml to SharedStyles.xaml looks like this:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>              
           <ResourceDictionary Source="/StyleLib;component/SharedStyles.xaml"/> 
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Now – I want SharedStyles.xaml of StyleLib to hold all specific style definitions, so I create a new file in the same project called ButtonStyles.xaml, and I add the resource there. Actually – I add another style too with a key to be used explicitly (technically I added this later, so this does not have anything to do with the problem that occurs).

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Style TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Red"></Setter>
    </Style>

    <Style x:Key="Explicit" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Blue"></Setter>
    </Style>    
</ResourceDictionary>

ButtonStyles.xaml is referenced from SharedStyles.xaml:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/StyleLib;component/ButtonStyles.xaml"/>
    </ResourceDictionary.MergedDictionaries>   
</ResourceDictionary>

Now – my button control is not styled any more. Actually – it is still shown as styled in the preview-window in VS2010, but when I run the application they aren’t styled. If I explicitly reference the style with key “Explicit” they get this style – so the file is successfully included.

Another funny thing is that if I now add another style in SharedStyle.xaml – e.g. a global style for StackPanel (which was what I tried) – then the global style inside ButtonStyle.xaml magically starts working..!

My question now is if I’m doing something wrong, or if this sounds like a bug in .Net4? Sounds like a bug to me.. This did work just fine in .Net3.5!

  • 1 1 Answer
  • 5 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:05:00+00:00Added an answer on May 14, 2026 at 3:05 pm

    I find this very odd. This did work just fine in .Net3.5, and I can see no reason why it shouldn’t work now!

    I reported this as a bug to Microsoft. You can view the bug report here. When they confirm the file the source code for the solution with the isolated problem should also be available there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application running with VS2010 .Net3.5 using Nhibernate with FluentNHibernate +
In my application (WPF) i have this window: public partial class Window1 : Window
We just ported our WinForms application to WPF. However, performance decreased dramatically. We have
I have a few WPF applications and I want all my styles to be
I have just installed a new ssl certificate on GlassFish 3. I also changed
How do you make this code work? Just have pyglet installed and change fireball.png
I have just created this table: create table dbo.OrderTypes ( ID smallint primary key
I have just installed composer in my /usr/bin folder, so when from that folder
I have a WPF Keyboard Application, it is developed in such a way that
i got this WPF application, and here i made a Splashscreen (wfp window) with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.