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

Changing color of SolidColorBrush don't cause a rerender #11673

Closed
SKProCH opened this issue Jun 6, 2023 · 9 comments · Fixed by #12146
Closed

Changing color of SolidColorBrush don't cause a rerender #11673

SKProCH opened this issue Jun 6, 2023 · 9 comments · Fixed by #12146
Labels

Comments

@SKProCH
Copy link
Contributor

SKProCH commented Jun 6, 2023

Describe the bug
When i change Color property of SolidColorBrush in resources it doesn't cause a rerender. It works in 11-preview*, but doesn't work in rc1-1

To Reproduce
Steps to reproduce the behavior:

  1. App.axaml:
<Application.Resources>
    <SolidColorBrush x:Key="MyBrush" Color="Aqua"></SolidColorBrush>
</Application.Resources>
  1. Window:
<StackPanel>
  <TextBlock Foreground="{DynamicResource MyBrush}">TEST TEXT</TextBlock>
  <Button Foreground="{DynamicResource MyBrush}" Click="Button_OnClick">CHANGE COLOR</Button>
  <Button Foreground="{DynamicResource MyBrush}">DUMMY</Button>
</StackPanel>
  1. Code behind:
private void Button_OnClick(object? sender, RoutedEventArgs e) {
    var solidColorBrush = App.Current.Resources["MyBrush"] as SolidColorBrush;
    var random = new Random();
    solidColorBrush.Color = Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255));
}

e138723d-ab24-444d-9a71-e9d02e862599

Desktop (please complete the following information):

  • Version: 11.0.0-rc1.1

Fast repro (also contains my other code, don't mind):
AvaloniaApplication1.zip

@danipen
Copy link

danipen commented Jun 6, 2023

Probably related (or duplicated) to #11036.

@SKProCH
Copy link
Contributor Author

SKProCH commented Jun 6, 2023

Yes, i think it related to your issue, @danipen

But i facing this issue only for rc1-1, not for preview*. I should check it again.

@workgroupengineering
Copy link
Contributor

if you change the code like this

        private void Button_OnClick(object? sender, RoutedEventArgs e)
        {
            var random = new Random();
            App.Current!.Resources["MyBrush"] = new SolidColorBrush()
            {
                Color = Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))
            };
        }

works.

@SKProCH
Copy link
Contributor Author

SKProCH commented Jun 6, 2023

Yep, I know this. But this is not a solution for me (I have a smooth transition between colors in Material.Avalonia)

@maxkatz6
Copy link
Member

maxkatz6 commented Jun 7, 2023

I think it's more related to this #11640 one and was already fixed in master.

@SKProCH
Copy link
Contributor Author

SKProCH commented Jun 7, 2023

@maxkatz6 I've tried the 11.0.999-cibuild0036218-beta and its partially fixed. But, for example, button foreground still doesn't get an update:
f02eb481-d5f4-4f64-841f-03745fb8aeb2

@SKProCH
Copy link
Contributor Author

SKProCH commented Jul 10, 2023

Seems like this issue strikes back in AvaloniaCommunity/Material.Avalonia#262

Update for Avalonia 11.0.0: still reproduceable as in my last comment. Here is an updated code: AvaloniaApplication1.zip

But i figured out some interesting details, if we put a control with a explicit binding after the button, button color changing start working.

<StackPanel>
  <Button Foreground="{DynamicResource MyBrush}" Click="Button_OnClick">CHANGE COLOR</Button>
  <Button Foreground="{DynamicResource MyBrush}">DUMMY</Button>
  <TextBlock Foreground="{DynamicResource MyBrush}">TEST TEXT</TextBlock>
</StackPanel>

But, if we put another button in the end 😆, it doesn't work:

<StackPanel>
  <Button Foreground="{DynamicResource MyBrush}" Click="Button_OnClick">CHANGE COLOR</Button>
  <Button Foreground="{DynamicResource MyBrush}">DUMMY</Button>
  <TextBlock Foreground="{DynamicResource MyBrush}">TEST TEXT</TextBlock>
  <Button Foreground="{DynamicResource MyBrush}">DUMMY</Button>
</StackPanel>

image

@kekekeks, @maxkatz6 i think what it's something compositor related, do you think?

@SKProCH
Copy link
Contributor Author

SKProCH commented Jul 10, 2023

Also, non of this were updated in previewer, may be this info will help:
image

@SKProCH
Copy link
Contributor Author

SKProCH commented Jul 13, 2023

Hmm, this case is actually resolved, but textboxes in Material.Avalonia still experiencing this issue. I think i need to create another repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants