Now that you're familiar with the basic shape controls available in Windows Phone 7, it's time to take a look at some of the color-management features. Although this isn't a terribly complex subject, you need to know the various ways you can construct colors for things like the SolidColorBrush object and basic Fill and Background properties of various controls.
As you've already seen, when working with XAML, you can easily type a color name into the Background, Foreground, and Fill properties of controls, and the Silverlight runtime will convert the string value into a valid color resource. When setting colors for various objects in XAML, you can choose from any valid HTML color code or you can use one of the string representations of the available colors. You can find a complete list of available colors in the online MSDN (www.msdn.microsoft.com) documentation by searching for the System.Colors enumeration.
Sometimes you need even more control of the color or need to set the color in the code-behind page. For example, if you have a new SolidColorBrush object and want to use one of the available colors, you'd probably expect to be able to use code similar to the following:
ContentPanel.Background = new SolidColorBrush(“SeaGreen”);
Unfortunately, this won't work. You can only use the color strings when setting the color in XAML. So how do you set the color in the code-behind? The first choice you have is to use one of the values available in the Colors enumeration, ...