Skip to content

NumberBox should respect Background/Foreground properties #2998

@Felix-Dev

Description

@Felix-Dev

Describe the bug
Currently, the NumberBox control does not respect its Background and Foreground APIs like the TextBox control does it. See the following XAML and the resulting UI:

<muxc:NumberBox MinWidth="200" 
        Foreground="Green" 
        Background="#FF404040"
        Header="NumberBox"
        Value="100"/>
<TextBox MinWidth="200" 
     Margin="0,10,0,0"
     Foreground="Green"
     Background="#FF404040"
     Header="TextBox"
     Text="Some text"/>

image

Expected behavior
image

Open questions
How should these two APIs affect the NumberBox control when it is in SpinButtonPlacementMode.Inline? Developers might want to dynamically change the foreground color of the NumberBox's input field depending on the actual value of the NumberBox. For example, color green for positive values and color red for negative values. As such, the NumberBox.Foreground API should only affect the foreground of the input box and not the foreground of the spin buttons as well. Consequently, the NumberBox.Background property should just affect the background of the input field too:
image

If developers also need to modify the foreground and/or background color of the spin buttons in inline mode, lightweight styling can be used. I have opened proposal #2844 which suggests adding a whole new set of NumberBox specific theme resources to give developers plenty of flexibility in styling their NumberBox controls.

Version Info
Newest WinUI master builds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions