I have a static class with statically defined HEX values of colors:
namespace Namespace1
{
public static class MyColors
{
public const string COLOR_1 = "#AABBCC";
// ...
}
}
I want to have all these colors defined in a resource dictionary so that they can be used in XAML:
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Namespace2.Style.Colors"
xmlns:n1="clr-namespace:Namespace1;assembly=Assembly1">
<Color x:Key="Color1" x:FactoryMethod="FromHex">
<x:Arguments>
<x:String>{x:Static n1:MyColors.COLOR_1}</x:String>
</x:Arguments>
</Color>
<!-- ... -->
</ResourceDictionary>
But this doesn't seem to work. There is no compile error, but the color itself is empty (transparent).
If I replace the {x:Static n1:MyColors.COLOR_1}
part with the actual #AABBCC
value, then it works.
I have also tested the {x:Static n1:MyColors.COLOR_1}
part (with Label and Text property) and it works.
So what is the problem here? This seems like an internal Xamarin.Forms bug.