Changing color of SolidColorBrush don't cause a rerender
See original GitHub issueDescribe 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:
- App.axaml:
<Application.Resources>
<SolidColorBrush x:Key="MyBrush" Color="Aqua"></SolidColorBrush>
</Application.Resources>
- 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>
- 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));
}
Desktop (please complete the following information):
- Version: 11.0.0-rc1.1
Fast repro (also contains my other code, don’t mind): AvaloniaApplication1.zip
Issue Analytics
- State:
- Created 3 months ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Change the color of a SolidcolorBrush resource with ...
This will change the background color based on the text value; if text is white, then the background is white, black, then background...
Read more >How to change the LineSeries2D.Brush color at runtime
My problem is that the chart does not update when I change the series brush color . How do I force a redraw?...
Read more >Best way to cache theme resources to avoid dynamic ...
We would like to bind the color values of our solid color resource brushes to the colors of brushes in your theme libraries....
Read more >Force Refresh() not working? - NinjaTrader Support Forum
The color of the plot corresponds to the label. As you can see the ForceRefresh() never makes the changes. Is there something I...
Read more >How can I change a svg image's color
Hi, I want to use a svg image as a SimpleButton's Glyph, and set it's foreground color blue. when I move mouse over...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
if you change the code like this
works.
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.