MAUI sample application has defined colors under “ResourceStylesColors.xaml”
This colors may be accessed via code.
Also there are colors defined in .csproj file like this:
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="ResourcesAppIconappicon.svg" ForegroundFile="ResourcesAppIconappiconfg.svg" Color="#538cc6" />
<!-- Splash Screen -->
<MauiSplashScreen Include="ResourcesSplashsplash.svg" Color="#538cc6" BaseSize="128,128" />
I just wonder is there any way to reference colors from resources instead of defining them as static colors.
Instead of this:
Color="#538cc6"
Somethingg like this:
Color="{Colors.Primary}"
Thanks in advance.
2
Is there any way to reference colors from resources instead of defining them as static colors.
This is the .csproj file, the file cannot use the resource dictionaries.
The document also mentioned about how to set the icon color.
Color values can be specified in hexadecimal, using the format: #RRGGBB or #AARRGGBB. The value of RR represents the red channel, GG the green channel, BB the blue channel, and AA the alpha channel. Instead of a hexadecimal value, you may use a named .NET MAUI color, such as Red or PaleVioletRed.
Color setting attributes can be removed from .csproj. They look like they are redundant here.