Skip to content

fix: Disabled Appearance="Primary" button renders white text on light background#1701

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-disabled-primary-button-foreground
Open

fix: Disabled Appearance="Primary" button renders white text on light background#1701
Copilot wants to merge 2 commits intomainfrom
copilot/fix-disabled-primary-button-foreground

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 30, 2026

Since 4.2.1, a ui:Button with Appearance="Primary" IsEnabled="False" renders white text on the grey disabled background — invisible in light theme.

Pull request type

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

WPF Style triggers have higher precedence than ControlTemplate triggers for the same dependency property. The Appearance="Primary" Style trigger sets Foreground = AccentButtonForeground (white). When the button is also disabled, the ControlTemplate's IsEnabled=False trigger attempts to set Foreground = ButtonForegroundDisabled, but is overridden by the Style-level Appearance trigger — leaving white text on a grey disabled background.

What is the new behavior?

  • An IsEnabled=False trigger is added at the end of Style.Triggers in DefaultUiButtonStyle, after all Appearance triggers.
  • Since WPF resolves conflicting Style triggers in declaration order (last wins), this ensures ButtonForegroundDisabled always overrides the Appearance foreground when the button is disabled — for all appearances.
<!--  DISABLED - must be last to override Appearance trigger foreground  -->
<Trigger Property="IsEnabled" Value="False">
    <Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" />
</Trigger>

Other information

Regression introduced by #1680, which moved the disabled foreground setter from per-element TargetName setters (inside ControlTemplate.Triggers) to a Style-level Foreground setter — exposing the trigger precedence conflict with Appearance triggers.

@pomianowski pomianowski changed the title [WIP] Fix white text rendering on disabled primary button fix(controls): [WIP] Fix white text rendering on disabled primary button Apr 30, 2026
Copilot AI changed the title fix(controls): [WIP] Fix white text rendering on disabled primary button fix: Disabled Appearance="Primary" button renders white text on light background Apr 30, 2026
Copilot AI requested a review from pomianowski April 30, 2026 10:27
@github-actions github-actions Bot added controls Changes to the appearance or logic of custom controls. styles Topic is related to styles PR Pull request release labels Apr 30, 2026
@pomianowski pomianowski marked this pull request as ready for review April 30, 2026 10:44
<!-- DISABLED - must be last to override Appearance trigger foreground -->
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" />
</Trigger>
Copy link
Copy Markdown
Contributor

@dkuaf dkuaf Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it should be better to move the Appearance triggers to inside the ControlTemplate.Triggers and position them before the existing triggers, i tested it and it works nicely. @pomianowski can i make another PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

controls Changes to the appearance or logic of custom controls. PR Pull request release styles Topic is related to styles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabled Appearance="Primary" button renders white text on light background (invisible) since 4.2.1

3 participants