#220 – Using the Predefined Colors

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">
				<SolidColorBrush Color="Blue"/>

Below is an image showing the full list of predefined colors.  (Click on the image to see it full size).


Get every new post delivered to your Inbox.

Join 356 other followers