-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[regression/8.0.0] DynamicResource not working with gradients when switching themes at runtime #18545
Comments
@davidortinau Can you help prioritize this issue? We have come across quite a few xaml resource issues recently , this area used to be solid in xamarin. |
We are affected too but this one. @samhouts is this part of any milestone? Inability to work with dynamic resources seems pretty important. |
Adding my voice here too - we are also impacted by this regression. Using DynamicResource colors in a gradient brush now crashes our app whereas it worked just fine on .NET 7. When can we expect a fix for this? Thanks. |
Also ran into this issue today when upgrading our project to .NET 8! |
@samhouts @jsuarezruiz @davidortinau Any updates on this? |
@davidortinau This is still a problem. is anyone looking into this? It would be a big task for us to use apptheme binding everywhere and add a "Light" and "Dark" version of each colour to the themes. We would have to add over 500 colors |
@StephaneDelcroix hi we are affected too.could u please give us an update on this.is this ever going to be fixed.Designers cannot understand why something simple is not supported as we cannot do what they want |
Adding voice to this, we are getting binding failures on Dynamic rosource bindings that previously worked: PS: the error description says it cannot convert from DynamicResource to Maui.Graphics.Color or Maui.Controls.brush. |
Bindings are immutable. and DynamicResources are only applied to Element. So I don't know what you expect to work there |
looking into this, but can not repro on today's main branch <Label x:Name="label" Text="Label" >
<Label.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Offset="0.1" Color="{DynamicResource GradientColorStart}" />
<GradientStop Offset="1.0" Color="{DynamicResource GradientColorEnd}" />
</LinearGradientBrush>
</Label.Background>
</Label> page.Resources = new ResourceDictionary
{
["GradientColorStart"] = Colors.Red,
["GradientColorEnd"] = Colors.Blue
};
Assert.That(page.label.Background, Is.TypeOf<LinearGradientBrush>());
var brush = (LinearGradientBrush)page.label.Background;
Assert.That(brush.GradientStops[0].Color, Is.EqualTo(Colors.Red));
page.Resources["GradientColorStart"] = Colors.Green;
Assert.That(brush.GradientStops[0].Color, Is.EqualTo(Colors.Green)); |
Hi @StephaneDelcroix , I just tried the project that I linked again and I am still getting the wrong behaviour. I even tried with the nightly "8.0.10-nightly.10055" and still nothing What version was you using which doesn't replicate? |
@StephaneDelcroix this is still an issue and looking at your test , you are not actually testing the issue but just checking if you can read the colors. that will read the correct colors with the current MergedDictionary The problem occurs when you switch theme at runtime , the gradient colors set for the light theme in our resource file are different from the one in the dark theme. and this only occurs with gradients.
|
The unittest tests that DynamicResources works inside gradients, which is the originally reported issue 😄 . Trying your 'let's switch themes' thing |
@developer9969 indeed, switching the theme at app level no longer propagate the resources changed event |
@StephaneDelcroix oh thank you for your prompt reply , yes that is the issue - I just hope it can be sorted as our design team as gone a bit mad with gradients... and users can switch between various themes.. |
* [C] Propagate resource changes to Background - fixes #18545 * apply same fix elsewhere
Description
When using a DynamicResource to change colors between light and dark mode in a gradient - .NET 8 no longer works. This worked fine in .NET7. The background stays on the light theme version the whole time.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/Zack-G-I-T/DynamicResourceNet8
Version with bug
8.0.0-preview.7.8842
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.96
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Using AppThemeBinding with Light and Dark, but our current app has two theme files for Light and Dark Theme so we use the same color names for both files. It will be very tedious to add "Dark" version to all the colours.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: