Skip to content

First Control in Visual Tree Ignores Styles from Nested ResourceDictionary in MergedDictionaries #11033

@NeroXc92

Description

@NeroXc92

Description

Microsoft Visual Studio Community 2022 - Preview
17.14.11 Preview 1.0

.NET 10 Preview 5

Issue:
When using ResourceDictionary.MergedDictionaries inside Resources, and defining styles in a nested dictionary (not from a separate file), the first control in the visual tree (e.g. CheckBox) does not apply the defined style (e.g. FontFamily).

Image

Reproduction Steps

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary>
                <Style TargetType="CheckBox">
                    <Setter Property="FontFamily" Value="Cascadia Code"/>
                </Style>
            </ResourceDictionary>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<WindowChrome.WindowChrome>
    <WindowChrome NonClientFrameEdges="None"
                  UseAeroCaptionButtons="False"
                  CaptionHeight="35"/>
</WindowChrome.WindowChrome>

<Grid Background="#1f1f1f">
    <StackPanel Width="320"
                VerticalAlignment="Center"
                HorizontalAlignment="Center">
        
        <CheckBox IsChecked="True" Content="check 1" Foreground="White" />
        <CheckBox IsChecked="True" Content="check 2" Foreground="White" />
        <CheckBox IsChecked="True" Content="check 3" Foreground="White" />
    </StackPanel>
</Grid>

Expected behavior

All CheckBoxes should use Cascadia Code.

Actual behavior

First CheckBox uses Segoe UI, others use Cascadia Code.

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions