#FFEEDD

Defining color as a static resource

I would like to be able to do the following:

... <Grid> <Grid.Resources> <Color x:Key="MyColor">#FFEEDD</Color> <Color x:Key="MyOtherColor">Green</Color> <!-- Use MyColor and MyOtherColor to define other resources... --> </Grid.Resources> </Grid> 

Unfortunately, I am forced to do this instead:

 ... <Grid> <Grid.Resources> <Color x:Key="MyColor" A="255" R="255" G="238" B="221" /> <Color x:Key="MyOtherColor" A="255" R="0" G="128" B="0" /> <!-- Use MyColor and MyOtherColor to define other resources... --> </Grid.Resources> </Grid> 

Because it seems that value converters don't kick. This is a royal pain in the grains, and I was wondering what can I do so that I can symbolically determine my colors and hexadecimal value?

+6
source share
1 answer

I'm not sure I understand your problem. I tried this and it worked. How do you use your color resources?

 <Grid> <Grid.Resources> <Color x:Key="MyColor">#FFEEDD</Color> <Color x:Key="MyOtherColor">Green</Color> </Grid.Resources> <Rectangle> <Rectangle.Fill> <SolidColorBrush Color="{StaticResource MyColor}"/> </Rectangle.Fill> </Rectangle> </Grid> 
+7
source share