Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot dynamically change controls' disabled background color, all though you can do it statically through custom dictionary. #9968

Closed
johnt-star opened this issue Sep 9, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@johnt-star
Copy link

Describe the bug

Not so much a bug as missing functionality.

Most controls can have their disabled background color statically set via a custom dictionary, by using an entry such as

( See #9989 where custom dictionary entry does not work )

My problem is that the user can change the background color of the container the control is on, so I need to dynamically change the Control's disabled background color.

Ideally, this could be done by exposing the controls disabled background color, the way it is currently done for background color.

In the meantime, in the following link, someone showed me how to access the elements of the Visual Tree for a check box

#9236

Could something like this be done for TextBox type controls (AutoSuggestBox, NumberBox, PasswordBox and TextBox) and the Button type controls (Button, HyperlinkButton, RadioButton, RadioButtons, RepeatButton, SplitButton, ToggleButton and ToggleSplitButton)?

Thank you in advance!

Steps to reproduce the bug

No control property to dynamically change the disabled back ground color.

Ideally the code would look similar to

    private void SetButtonBackGroundDisabledColor(Windows.UI.Color color)
    {
            Button.DisabledBackground = new SolidColorBrush(color);
    }

Can only do it statically in a custom dictionary by adding following line:

Expected behavior

No response

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

@johnt-star johnt-star added the bug Something isn't working label Sep 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Sep 10, 2024
@castorix
Copy link

You can do :

private void SetButtonBackGroundDisabledColor(Button btn, Windows.UI.Color color)
{ 
    btn.Resources["ButtonBackgroundDisabled"] = new SolidColorBrush(color);
}

@johnt-star
Copy link
Author

Thanks for the reply!

I verified this works.

I also like the methodology and can use it elsewhere in my code.

Will close this ticket

@johnt-star
Copy link
Author

Will use suggested code to achieve what I need

@microsoft-github-policy-service microsoft-github-policy-service bot added needs-triage Issue needs to be triaged by the area owners and removed needs-triage Issue needs to be triaged by the area owners labels Sep 10, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants