Skip to content

Correct styles not loaded on including ResourceDictionary directly in Application.Resources merged dictionaries #10824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
siagupta0202 opened this issue May 2, 2025 · 1 comment
Labels
Discuss In WPF Team Triage Investigate Requires further investigation by the WPF team.

Comments

@siagupta0202
Copy link
Contributor

siagupta0202 commented May 2, 2025

Description

Styles are not applied correctly when trying to add a ResourceDictionary directly in the Application.Resources merged dictionaries as following :

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.Light.xaml" />

            <ResourceDictionary>
                  <!-- Content of Dictionary1.xaml -->
            </ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

When I add the resources as above, the first ComboBox and ComboBoxItem (in the sample app) do not pick up any style and defaults to Aero2, however subsequent ComboBox and ComboBoxItem pick the correct style.

Now, when I add the content of resource dictionary in a separate file and refer that file in Application.Resources as follows, the issue does not occur.
Eg:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/PresentationFramework.Fluent;component/Themes/Fluent.Light.xaml" />

            <ResourceDictionary Source="/Dictionary1.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Reproduction Steps

  1. Run the application attached and notice that the left ComboBox and the first element of the left ComboBox are aero styled whereas the rest are fluent styled
  2. Go to App.xaml, remove the second ResourceDictionary from Application.Resources and instead add <ResourceDictiony Source="/Dictionary1.xaml" />
  3. Run the app again and notice that the results produced are now correct.

Expected behavior

Style should be correctly applied

Image

Actual behavior

Style is not getting applied correctly

Image

Regression?

No, this issue is reproducible on .NET 8 as well

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

@miloush
Copy link
Contributor

miloush commented May 2, 2025

Duplicate of #2286?

@siagupta0202 siagupta0202 added the Investigate Requires further investigation by the WPF team. label May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discuss In WPF Team Triage Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

2 participants