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

Textbox border not updating after theme change until clicked #321

Closed
melsawy93 opened this issue Nov 20, 2023 · 5 comments
Closed

Textbox border not updating after theme change until clicked #321

melsawy93 opened this issue Nov 20, 2023 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@melsawy93
Copy link

melsawy93 commented Nov 20, 2023

I have a textbox:

<TextBox
    Grid.Column="0"
    Width="225"
    VerticalAlignment="Center"
    p1:TextFieldAssist.Label="Search Tools"
    Classes="solo dense clearButton"
    Text="{Binding SearchText, Mode=TwoWay}"
    Theme="{StaticResource OutlineTextBox}" />

I have a button to flip the theme of my app via:

public void ToggleBaseThemeMode()
{
    if (_isLightTheme)
    {
        // Switch to Dark Theme
        Theme theme = Theme.Create(Theme.Dark, _primaryColor, SwatchHelper.Lookup[(MaterialColor)SecondaryColor.Lime]);
        _materialThemeBase.CurrentTheme = theme;
    }
    else
    {
        // Switch to Light Theme
        Theme theme = Theme.Create(Theme.Light, _primaryColor, SwatchHelper.Lookup[(MaterialColor)SecondaryColor.Lime]);
        _materialThemeBase.CurrentTheme = theme;
    }

    _isLightTheme = !_isLightTheme; // Toggle the theme state
}

I have noticed when flipping the theme, the borderbrush of my textbox doesnt get changed until I "click" into the textbox and it somehow refreshes? Is there someway to force it to change? See gif below:
Animation

@SKProCH
Copy link
Collaborator

SKProCH commented Nov 20, 2023

This is issue on Avalonia side.

Also, duplicate of #262

@SKProCH SKProCH closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2023
@SKProCH SKProCH added the duplicate This issue or pull request already exists label Nov 20, 2023
@melsawy93
Copy link
Author

Thanks, I missed the original issue, are you aware of any workaround? I will follow up with the issue on the avalonia side that you have opened.

@SKProCH
Copy link
Collaborator

SKProCH commented Nov 20, 2023

I was thinking about removing and re-adding the necessary brushes that are used in the TextBox when the theme changes. I assume that this should be done in the MaterialTheme/MaterialThemeBase class. I did a similar workaround for a similar bug some time ago.

If you experiment, please let me know the results. I'm also planning to do some tests on this, but I'm not sure when I'll have free time to do it.

@melsawy93
Copy link
Author

I was thinking about removing and re-adding the necessary brushes that are used in the TextBox when the theme changes. I assume that this should be done in the MaterialTheme/MaterialThemeBase class. I did a similar workaround for a similar bug some time ago.

If you experiment, please let me know the results. I'm also planning to do some tests on this, but I'm not sure when I'll have free time to do it.

Happy to look further into this, but I need to make sure I understand you correctly as this is all new to me. Are you saying when setting the theme in MaterialThemeBase, I should also look at which brushes inside the materialThemebase and re-assign them?

@SKProCH
Copy link
Collaborator

SKProCH commented Nov 20, 2023

Yep. You can also look to commit history of these files and you should find the required code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants