February 17, 2011 2 Comments
The Colors class, in the System.Windows.Media namespace, includes a large set of static properties representing a set of predefined colors. Each property has a name representing the color, e.g. “Blue”, and is stored internally as a standard WPF Color structure.
The example below shows two different ways of using the predefined colors. You can use a color name in XAML wherever either a color or a brush is expected. The name of the color in XAML is converted to a Color value by mapping the name of the color to one of the properties in the Colors class.
<Button Content="Hello" Background="Purple" /> <Button Content="Again"> <Button.Background> <SolidColorBrush Color="Blue"/> </Button.Background> </Button>
Below is an image showing the full list of predefined colors. (Click on the image to see it full size).