Closed devastaza closed 11 months ago
Are you sure the exact same thing worked in .NET 7? There shouldn't be any reason DynamicResource wouldn't work in .NET 8, though not everything "accepts" them if I remember correctly. Without seeing actual code I can't confirm anything right now. Could be a bug in the IDE, intended behavior change in .NET 8 or even a typo in your code.
Sure, i'll try to explain my problem.
This part of code from .xaml file.
<Label
Text = "D"
TextColor = "{DynamicResource Primary}"
FontSize = "22"/>
It setup the "D" you can see on screenshot belove.
So i can change value of my "Primary" key by pressing buttons on this page. ...And i change it.
And look, other objects change its background colors (cuz they have no setter {DynamicResource Primary})
For example there is a wide button's code
<Button
Text = "Dynamic Colors [Experimental]"
Margin = "15"
HeightRequest = "90"
Clicked = "EnableDynamicColors"/>
And there is code from Styles.xml which setup all of my objects in this project.
<Style TargetType="Button">
<Setter Property="BackgroundColor" Value="{DynamicResource Primary}" />
And this code worked on previous version of .net.
@devastaza Here is a .NET 8 test project. It qualifies as DynamicResources. And it works exactly the same under Windows and C# Shell. Maybe this is an light/dark theme thing? C# Shell should support these themes now, but I don't think it did before.
MauiAppDynamicResourceTest.zip
https://github.com/radimitrov/CSharpShellApp/assets/56889141/ddf66af8-86dc-434a-8840-b4d5fa9d153b
@radimitrov i modified your example with DynamicResource properties and it works perfectly. Idk where is problem in my project. Btw thank u!
But it works in Styles.xaml file only. If i set BackgroundColor = from DynamicResource then after changing value of key object doesn't change it's color.