lepoco / lepoco/wpfui

In WPF-UI version 4.0.3, it is no longer possible to override global control styles (e.g., TextBlock.FontSize) from App.xaml using implicit styles

Open
#1,459 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

First of all, thank you for your continued work on WPF-UI — it's a fantastic library that has greatly improved the developer experience in our WPF projects.

In WPF-UI version 4.0.3, setting a global implicit style for ui:TextBlock in App.xaml does not override the default FontSize applied by the library. Even after explicitly defining a style like this:

<Style TargetType="ui:TextBlock">
    <Setter Property="FontSize" Value="40" />
</Style>

the actual FontSize of ui:TextBlock elements remains 14, as confirmed in the Properties window at runtime.
This behavior differs from WPF-UI 3.x and even 4.0.0, where such global styles were correctly applied.

To Reproduce

For example, in App.xaml:
Add an implicit style for ui:TextBlock with FontSize = 40 in App.xaml.

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--<ResourceDictionary
                    Source="pack://application:,,,/Wpf.Ui;component/Resources/Wpf.Ui.xaml" />-->

                <ResourceDictionary
                    Source="pack://application:,,,/Wpf.Ui;component/Controls/TextBlock/TextBlock.xaml" />
                <ResourceDictionary
                    Source="pack://application:,,,/Wpf.Ui;component/Controls/TextBox/TextBox.xaml" />

                <ui:ControlsDictionary />
            </ResourceDictionary.MergedDictionaries>

            <Style
                TargetType="ui:TextBlock">
                <Setter Property="FontSize" Value="40" />
            </Style>

            <Style
                TargetType="TextBlock">
                <Setter Property="FontSize" Value="40" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>

in MainWindow.xaml:

    <StackPanel
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Orientation="Horizontal">

        <StackPanel
            Margin="8">
            <ui:TextBlock
                Text="ui:TextBlock A" />
            <ui:TextBlock
                FontSize="30"
                Text="ui:TextBlock B" />
        </StackPanel>

        <StackPanel
            Margin="8">
            <TextBlock
                Text="TextBlock A" />
            <TextBlock
                FontSize="30"
                Text="TextBlock B" />
        </StackPanel>
    </StackPanel>
Expected behavior

The FontSize of ui:TextBlock should reflect the value defined in App.xaml — in this case, 40 — and should be visible as such in the property panel at runtime.

Screenshots

Image

Image

Image

OS version

Windows 11

.NET version

net9.0

WPF-UI NuGet version

4.0.3

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the implicit-style behavior from App.xaml with the controls and resource dictionaries shown in the report, then compare it with WPF-UI 4.0.0 or 3.x. Inspect the TextBlock resources and MainWindow.xaml example to identify why the App.xaml FontSize setter is not effective in 4.0.3. Done means the ui:TextBlock style sets FontSize to 40 while explicit element values still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.