Hello,
You can refer to the following code to access the Color you defined inside the Resources
->Colors.xaml
ResourceDictionary ColorResource = Application.Current.Resources.MergedDictionaries.FirstOrDefault() as ResourceDictionary;
Color lightcolor = ColorResource["ConnectedIconLight"] as Color;
Color darkcolor = ColorResource["ConnectedIconDark"] as Color;
LabelStatus.SetAppThemeColor(Label.TextColorProperty, lightcolor, darkcolor);
It's recommended that you use the StaticResource
markup extension if you don't need to change the app theme at runtime.
For more details, you can refer to
Theme an app - .NET MAUI | Microsoft Learn
Resource dictionaries - .NET MAUI | Microsoft Learn
Consume XAML markup extensions - .NET MAUI | Microsoft Learn
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.