Skip to content

fix(controls): Button foreground on pressed showing wrong color in dark mode#1733

Open
JyslaFancy wants to merge 1 commit into
lepoco:mainfrom
JyslaFancy:fix/issue-1722-button-pressed-foreground-dark-mode
Open

fix(controls): Button foreground on pressed showing wrong color in dark mode#1733
JyslaFancy wants to merge 1 commit into
lepoco:mainfrom
JyslaFancy:fix/issue-1722-button-pressed-foreground-dark-mode

Conversation

@JyslaFancy

Copy link
Copy Markdown

Description

Fixes #1722

Root Cause

Commit 4c711b6 (released in v4.2.1) changed the IsPressed MultiTrigger and IsEnabled (Disabled) trigger in the ControlTemplate from directly setting on and to setting on the TemplatedParent (Button), relying on to propagate the value to the ContentPresenter elements.

However, WPF's does not always properly reflect trigger-set values on the templated parent. When a ControlTemplate trigger sets on the parent Button, the TemplateBinding on the ContentPresenter may fail to pick up this change, causing the ContentPresenter to use the default value () instead of the Style-setter value ().

In dark theme, this results in the button text showing the wrong (dark) color when pressed.

Fix

Restored the direct setters on and in both the IsPressed MultiTrigger and the IsEnabled (Disabled) trigger, matching the working approach from v4.2.0.

…n ControlTemplate triggers

Commit 4c711b6 (v4.2.1) changed the IsPressed and Disabled ControlTemplate
triggers to set Foreground on the TemplatedParent instead of directly setting
TextElement.Foreground on the ContentPresenter and ControlIcon elements.
This relied on {TemplateBinding Foreground} to propagate the value, but
TemplateBinding does not always properly reflect trigger-set values on the
templated parent. In dark theme, this caused the button foreground to show
the wrong color when pressed (falling back to the PressedForeground DP
default of SystemColors.ControlTextBrush instead of the Style-set
ButtonForegroundPressed resource).

The fix restores the working approach from v4.2.0: directly targeting
ContentPresenter and ControlIcon with TextElement.Foreground in both the
IsPressed MultiTrigger and the IsEnabled (Disabled) Trigger.

Fixes lepoco#1722
@JyslaFancy JyslaFancy requested a review from pomianowski as a code owner June 12, 2026 23:25
@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 Jun 12, 2026
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.

[Bug] After 4.2.1, ui:Button foreground error on pressed

1 participant