In ./Styles/Colors.xaml
I have a bunch of colors like this:
<Color x:Key="IIT_Purple">#6A00FF</Color>
Which I can reference in my platform-non-specific XAML code without any problems, using {StaticResource IIT_Purple}
.
However when I try to reference them the same way in ./Platforms/Windows/App.xaml
the program hits a break with an unhandled exception:
(Click to enlarge)
If I duplicate the <Color>
‘s from ./Styles/Colors.xaml
in to ./Platforms/Windows/App.xaml
then they work perfectly – but this goes against the DRY/WET principle since it is duplicating the code.
Similarly in ./Platforms/Windows/App.xaml.cs
I have had to duplicate the colors again, like so:
var IIT_Purple = Color.FromArgb("#6A00FF").ToWindowsColor();
How can I reference the colors that are in ./Styles/Colors.xaml
from within the WinUI platform-specific code please? Both in ./Platforms/Windows/App.xaml
as well as ./Platforms/Windows/App.xaml.cs
.