Skip to content

Conversation

@mou-haz
Copy link
Contributor

@mou-haz mou-haz commented Jan 5, 2026

According to the case reported by @Jack251970 in reply, it seems in some cases the included merged resource dictionaries don't provide the correct theme resources (it seems to only provide the light theme resources by default?).

This PR uses a custom RepeatButton style that uses the needed resources instead.

Remaining issues:
Popup icons.

After changes:

numberBox.mp4

@mou-haz mou-haz marked this pull request as draft January 5, 2026 14:53
@mou-haz mou-haz mentioned this pull request Jan 5, 2026
sometimes fontfamily of ContentPresenterEx is not propagated to its textblock content.
In this case, the content of the repeat button is text, so a textblock is used instead.
@Jack251970
Copy link
Contributor

@mou-haz Hi, thanks for your fix! It seems that I cannot conduct the test locally and I do not seem to know how to package UI.WPF.Modern locally (at least the nuget packages packaged by the Pack option in VS cannot work). Could you please tell me the steps to test it locally?

@mou-haz
Copy link
Contributor Author

mou-haz commented Jan 7, 2026

I use a project reference instead of a nuget (these are the changes i used).
I tried packing the project as nuget and didn't work for me also.
For nuget packing this worked for me.

I think this branch will be better for testing since it also has the expander fix.

Copy link
Contributor

@Jack251970 Jack251970 left a comment

Choose a reason for hiding this comment

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

It works for me! Thanks for your quick fix!!!❤️

@mou-haz
Copy link
Contributor Author

mou-haz commented Jan 7, 2026

It works for me! Thanks for your quick fix!!!❤️

Glad it worked ! you are welcome.

@mou-haz mou-haz marked this pull request as ready for review January 7, 2026 13:49
@NotYoojun NotYoojun requested review from NotYoojun and Copilot January 9, 2026 06:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a theming issue in the NumberBox control where theme resources were not switching properly between light and dark themes. The fix replaces the merged resource dictionaries approach with a custom RepeatButton template that directly references theme resources.

Key changes:

  • Added a custom RepeatButton template with direct DynamicResource references to TextControlButton* resources
  • Removed Grid.Resources section with theme-specific resource mappings
  • Added Foreground and FocusVisualStyle setters to the NumberBoxSpinButtonStyle

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Value="{DynamicResource RepeatButtonBackgroundDisabled}" />
<Setter TargetName="Background"
Property="BorderBrush"
Value="{DynamicResource TextControlButtonBorderBrushDisabled}" />
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The resource key "TextControlButtonBorderBrushDisabled" does not exist in any of the theme resource dictionaries (Light, Dark, or HighContrast). This will cause a runtime error when the button is disabled. Based on other TextControlButton implementations in the codebase (e.g., in TextBox.xaml and PasswordBox.xaml), the disabled state either uses Opacity=0 or should use the base "TextControlButtonBorderBrush" resource without a state suffix.

Suggested change
Value="{DynamicResource TextControlButtonBorderBrushDisabled}" />
Value="{DynamicResource TextControlBorderBrush}" />

Copilot uses AI. Check for mistakes.
Value="{DynamicResource RepeatButtonBackgroundDisabled}" />
<Setter TargetName="Background"
Property="BorderBrush"
Value="{DynamicResource TextControlButtonBorderBrushDisabled}" />
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

There's an inconsistency in resource naming for the disabled state. Lines 92 and 98 use "RepeatButtonDisabled" resources, while line 95 uses "TextControlButtonBorderBrushDisabled" (which doesn't exist). For consistency with the rest of the template which uses "TextControlButton" resources, the disabled state should either: 1) Use TextControlButton resources (like "TextControlButtonBackground" without state suffix), or 2) Follow the pattern used in TextBox/PasswordBox controls by setting Opacity to 0 for the disabled state.

Suggested change
Value="{DynamicResource TextControlButtonBorderBrushDisabled}" />
Value="{DynamicResource TextControlButtonBorderBrush}" />

Copilot uses AI. Check for mistakes.
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
Text="{TemplateBinding Content}"
FontFamily="{TemplateBinding FontFamily}"
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The TextBlock does not have a Foreground binding. While the style sets a Foreground property at line 38, the TextBlock will not automatically use it unless explicitly bound. The triggers set TextElement.Foreground on the ContentPresenter for hover and pressed states (lines 73-74, 85-86), but the normal state doesn't have a foreground binding. Add "Foreground="{TemplateBinding Foreground}"" or "TextElement.Foreground="{TemplateBinding Foreground}"" to the TextBlock to ensure the initial foreground color is applied correctly.

Suggested change
FontFamily="{TemplateBinding FontFamily}"
FontFamily="{TemplateBinding FontFamily}"
Foreground="{TemplateBinding Foreground}"

Copilot uses AI. Check for mistakes.
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False"
Text="{TemplateBinding Content}"
FontFamily="{TemplateBinding FontFamily}"
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The TextBlock is missing a FontSize binding. While line 35 sets FontSize="12" on the style, and the RepeatButton instances set their own FontSize (lines 469, 480), the TextBlock should explicitly bind to TemplateBinding FontSize to respect the FontSize property. Add "FontSize="{TemplateBinding FontSize}"" to ensure the font size is correctly applied from the control's FontSize property.

Suggested change
FontFamily="{TemplateBinding FontFamily}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants