There's a wide variety of colors available when setting colors in XAML in Silverlight, but the options seem limited when dealing with setting colors programmatically.
For example, in Silverlight XAML I can set a Background to "Alice Blue", "Antique White", etc.
But if I try to set that same background in the code-behind, I'm limited to a fairly finite set of colors based on the Colors class... Black, Blue, Brown...White, Yellow. These come into play with something like:
uxPanel.Background = new SolidColorBrush (Colors.Green);
I know I can set any color I'd like via RGB values, as in (where colorsString is something like "112345"):
var brush = new SolidColorBrush ();
var c = new Color
{
A = 0xFF,
R = Convert.ToByte (colorString.Substring (0, 2), 16),
G = Convert.ToByte (colorString.Substring (2, 2), 16),
B = Convert.ToByte (colorString.Substring (4, 2), 16)
};
brush.Color = c;
return (brush);
But how can I tap into the wider variety of color names accessible in XAML or via a style, but set programmatically in my code-behind? Or is this not possible in Silverlight?