1 out of 5 rated this helpful - Rate this topic

Colors Class

Implements a set of predefined colors.

System.Object
  System.Windows.Media.Colors

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public sealed class Colors
You cannot declare this managed class in XAML, but you can use its static properties to assign values in XAML.

The Colors type exposes the following members.

  Name Description
Public property Static member AliceBlue Gets the system-defined color that has an ARGB value of #FFF0F8FF.
Public property Static member AntiqueWhite Gets the system-defined color that has an ARGB value of #FFFAEBD7.
Public property Static member Aqua Gets the system-defined color that has an ARGB value of #FF00FFFF.
Public property Static member Aquamarine Gets the system-defined color that has an ARGB value of #FF7FFFD4.
Public property Static member Azure Gets the system-defined color that has an ARGB value of #FFF0FFFF.
Public property Static member Beige Gets the system-defined color that has an ARGB value of #FFF5F5DC.
Public property Static member Bisque Gets the system-defined color that has an ARGB value of #FFFFE4C4.
Public property Static member Black Gets the system-defined color that has an ARGB value of #FF000000.
Public property Static member BlanchedAlmond Gets the system-defined color that has an ARGB value of #FFFFEBCD.
Public property Static member Blue Gets the system-defined color that has an ARGB value of #FF0000FF.
Public property Static member BlueViolet Gets the system-defined color that has an ARGB value of #FF8A2BE2.
Public property Static member Brown Gets the system-defined color that has an ARGB value of #FFA52A2A.
Public property Static member BurlyWood Gets the system-defined color that has an ARGB value of #FFDEB887.
Public property Static member CadetBlue Gets the system-defined color that has an ARGB value of #FF5F9EA0.
Public property Static member Chartreuse Gets the system-defined color that has an ARGB value of #FF7FFF00.
Public property Static member Chocolate Gets the system-defined color that has an ARGB value of #FFD2691E.
Public property Static member Coral Gets the system-defined color that has an ARGB value of #FFFF7F50.
Public property Static member CornflowerBlue Gets the system-defined color that has an ARGB value of #FF6495ED.
Public property Static member Cornsilk Gets the system-defined color that has an ARGB value of #FFFFF8DC.
Public property Static member Crimson Gets the system-defined color that has an ARGB value of #FFDC143C.
Public property Static member Cyan Gets the system-defined color that has an ARGB value of #FF00FFFF.
Public property Static member DarkBlue Gets the system-defined color that has an ARGB value of #FF00008B.
Public property Static member DarkCyan Gets the system-defined color that has an ARGB value of #FF008B8B.
Public property Static member DarkGoldenrod Gets the system-defined color that has an ARGB value of #FFB8860B.
Public property Static member DarkGray Gets the system-defined color that has an ARGB value of #FFA9A9A9.
Public property Static member DarkGreen Gets the system-defined color that has an ARGB value of #FF006400.
Public property Static member DarkKhaki Gets the system-defined color that has an ARGB value of #FFBDB76B.
Public property Static member DarkMagenta Gets the system-defined color that has an ARGB value of #FF8B008B.
Public property Static member DarkOliveGreen Gets the system-defined color that has an ARGB value of #FF556B2F.
Public property Static member DarkOrange Gets the system-defined color that has an ARGB value of #FFFF8C00.
Public property Static member DarkOrchid Gets the system-defined color that has an ARGB value of #FF9932CC.
Public property Static member DarkRed Gets the system-defined color that has an ARGB value of #FF8B0000.
Public property Static member DarkSalmon Gets the system-defined color that has an ARGB value of #FFE9967A.
Public property Static member DarkSeaGreen Gets the system-defined color that has an ARGB value of #FF8FBC8F.
Public property Static member DarkSlateBlue Gets the system-defined color that has an ARGB value of #FF483D8B.
Public property Static member DarkSlateGray Gets the system-defined color that has an ARGB value of #FF2F4F4F.
Public property Static member DarkTurquoise Gets the system-defined color that has an ARGB value of #FF00CED1.
Public property Static member DarkViolet Gets the system-defined color that has an ARGB value of #FF9400D3.
Public property Static member DeepPink Gets the system-defined color that has an ARGB value of #FFFF1493.
Public property Static member DeepSkyBlue Gets the system-defined color that has an ARGB value of #FF00BFFF.
Public property Static member DimGray Gets the system-defined color that has an ARGB value of #FF696969.
Public property Static member DodgerBlue Gets the system-defined color that has an ARGB value of #FF1E90FF.
Public property Static member Firebrick Gets the system-defined color that has an ARGB value of #FFB22222.
Public property Static member FloralWhite Gets the system-defined color that has an ARGB value of #FFFFFAF0.
Public property Static member ForestGreen Gets the system-defined color that has an ARGB value of #FF228B22.
Public property Static member Fuchsia Gets the system-defined color that has an ARGB value of #FFFF00FF.
Public property Static member Gainsboro Gets the system-defined color that has an ARGB value of #FFDCDCDC.
Public property Static member GhostWhite Gets the system-defined color that has an ARGB value of #FFF8F8FF.
Public property Static member Gold Gets the system-defined color that has an ARGB value of #FFFFD700.
Public property Static member Goldenrod Gets the system-defined color that has an ARGB value of #FFDAA520.
Public property Static member Gray Gets the system-defined color that has an ARGB value of #FF808080.
Public property Static member Green Gets the system-defined color that has an ARGB value of #FF008000.
Public property Static member GreenYellow Gets the system-defined color that has an ARGB value of #FFADFF2F.
Public property Static member Honeydew Gets the system-defined color that has an ARGB value of #FFF0FFF0.
Public property Static member HotPink Gets the system-defined color that has an ARGB value of #FFFF69B4.
Public property Static member IndianRed Gets the system-defined color that has an ARGB value of #FFCD5C5C.
Public property Static member Indigo Gets the system-defined color that has an ARGB value of #FF4B0082.
Public property Static member Ivory Gets the system-defined color that has an ARGB value of #FFFFFFF0.
Public property Static member Khaki Gets the system-defined color that has an ARGB value of #FFF0E68C.
Public property Static member Lavender Gets the system-defined color that has an ARGB value of #FFE6E6FA.
Public property Static member LavenderBlush Gets the system-defined color that has an ARGB value of #FFFFF0F5.
Public property Static member LawnGreen Gets the system-defined color that has an ARGB value of #FF7CFC00.
Public property Static member LemonChiffon Gets the system-defined color that has an ARGB value of #FFFFFACD.
Public property Static member LightBlue Gets the system-defined color that has an ARGB value of #FFADD8E6.
Public property Static member LightCoral Gets the system-defined color that has an ARGB value of #FFF08080.
Public property Static member LightCyan Gets the system-defined color that has an ARGB value of #FFE0FFFF.
Public property Static member LightGoldenrodYellow Gets the system-defined color that has an ARGB value of #FFFAFAD2.
Public property Static member LightGray Gets the system-defined color that has an ARGB value of #FFD3D3D3.
Public property Static member LightGreen Gets the system-defined color that has an ARGB value of #FF90EE90.
Public property Static member LightPink Gets the system-defined color that has an ARGB value of #FFFFB6C1.
Public property Static member LightSalmon Gets the system-defined color that has an ARGB value of #FFFFA07A.
Public property Static member LightSeaGreen Gets the system-defined color that has an ARGB value of #FF20B2AA.
Public property Static member LightSkyBlue Gets the system-defined color that has an ARGB value of #FF87CEFA.
Public property Static member LightSlateGray Gets the system-defined color that has an ARGB value of #FF778899.
Public property Static member LightSteelBlue Gets the system-defined color that has an ARGB value of #FFB0C4DE.
Public property Static member LightYellow Gets the system-defined color that has an ARGB value of #FFFFFFE0.
Public property Static member Lime Gets the system-defined color that has an ARGB value of #FF00FF00.
Public property Static member LimeGreen Gets the system-defined color that has an ARGB value of #FF32CD32.
Public property Static member Linen Gets the system-defined color that has an ARGB value of #FFFAF0E6.
Public property Static member Magenta Gets the system-defined color that has an ARGB value of #FFFF00FF.
Public property Static member Maroon Gets the system-defined color that has an ARGB value of #FF800000.
Public property Static member MediumAquamarine Gets the system-defined color that has an ARGB value of #FF66CDAA.
Public property Static member MediumBlue Gets the system-defined color that has an ARGB value of #FF0000CD.
Public property Static member MediumOrchid Gets the system-defined color that has an ARGB value of #FFBA55D3.
Public property Static member MediumPurple Gets the system-defined color that has an ARGB value of #FF9370DB.
Public property Static member MediumSeaGreen Gets the system-defined color that has an ARGB value of #FF3CB371.
Public property Static member MediumSlateBlue Gets the system-defined color that has an ARGB value of #FF7B68EE.
Public property Static member MediumSpringGreen Gets the system-defined color that has an ARGB value of #FF00FA9A.
Public property Static member MediumTurquoise Gets the system-defined color that has an ARGB value of #FF48D1CC.
Public property Static member MediumVioletRed Gets the system-defined color that has an ARGB value of #FFC71585.
Public property Static member MidnightBlue Gets the system-defined color that has an ARGB value of #FF191970.
Public property Static member MintCream Gets the system-defined color that has an ARGB value of #FFF5FFFA.
Public property Static member MistyRose Gets the system-defined color that has an ARGB value of #FFFFE4E1.
Public property Static member Moccasin Gets the system-defined color that has an ARGB value of #FFFFE4B5.
Public property Static member NavajoWhite Gets the system-defined color that has an ARGB value of #FFFFDEAD.
Public property Static member Navy Gets the system-defined color that has an ARGB value of #FF000080.
Public property Static member OldLace Gets the system-defined color that has an ARGB value of #FFFDF5E6.
Public property Static member Olive Gets the system-defined color that has an ARGB value of #FF808000.
Public property Static member OliveDrab Gets the system-defined color that has an ARGB value of #FF6B8E23.
Public property Static member Orange Gets the system-defined color that has an ARGB value of #FFFFA500.
Public property Static member OrangeRed Gets the system-defined color that has an ARGB value of #FFFF4500.
Public property Static member Orchid Gets the system-defined color that has an ARGB value of #FFDA70D6.
Public property Static member PaleGoldenrod Gets the system-defined color that has an ARGB value of #FFEEE8AA.
Public property Static member PaleGreen Gets the system-defined color that has an ARGB value of #FF98FB98.
Public property Static member PaleTurquoise Gets the system-defined color that has an ARGB value of #FFAFEEEE.
Public property Static member PaleVioletRed Gets the system-defined color that has an ARGB value of #FFDB7093.
Public property Static member PapayaWhip Gets the system-defined color that has an ARGB value of #FFFFEFD5.
Public property Static member PeachPuff Gets the system-defined color that has an ARGB value of #FFFFDAB9.
Public property Static member Peru Gets the system-defined color that has an ARGB value of #FFCD853F.
Public property Static member Pink Gets the system-defined color that has an ARGB value of #FFFFC0CB.
Public property Static member Plum Gets the system-defined color that has an ARGB value of #FFDDA0DD.
Public property Static member PowderBlue Gets the system-defined color that has an ARGB value of #FFB0E0E6.
Public property Static member Purple Gets the system-defined color that has an ARGB value of #FF800080.
Public property Static member Red Gets the system-defined color that has an ARGB value of #FFFF0000.
Public property Static member RosyBrown Gets the system-defined color that has an ARGB value of #FFBC8F8F.
Public property Static member RoyalBlue Gets the system-defined color that has an ARGB value of #FF4169E1.
Public property Static member SaddleBrown Gets the system-defined color that has an ARGB value of #FF8B4513.
Public property Static member Salmon Gets the system-defined color that has an ARGB value of #FFFA8072.
Public property Static member SandyBrown Gets the system-defined color that has an ARGB value of #FFF4A460.
Public property Static member SeaGreen Gets the system-defined color that has an ARGB value of #FF2E8B57.
Public property Static member SeaShell Gets the system-defined color that has an ARGB value of #FFFFF5EE.
Public property Static member Sienna Gets the system-defined color that has an ARGB value of #FFA0522D.
Public property Static member Silver Gets the system-defined color that has an ARGB value of #FFC0C0C0.
Public property Static member SkyBlue Gets the system-defined color that has an ARGB value of #FF87CEEB.
Public property Static member SlateBlue Gets the system-defined color that has an ARGB value of #FF6A5ACD.
Public property Static member SlateGray Gets the system-defined color that has an ARGB value of #FF708090.
Public property Static member Snow Gets the system-defined color that has an ARGB value of #FFFFFAFA.
Public property Static member SpringGreen Gets the system-defined color that has an ARGB value of #FF00FF7F.
Public property Static member SteelBlue Gets the system-defined color that has an ARGB value of #FF4682B4.
Public property Static member Tan Gets the system-defined color that has an ARGB value of #FFD2B48C.
Public property Static member Teal Gets the system-defined color that has an ARGB value of #FF008080.
Public property Static member Thistle Gets the system-defined color that has an ARGB value of #FFD8BFD8.
Public property Static member Tomato Gets the system-defined color that has an ARGB value of #FFFF6347.
Public property Static member Transparent Gets the system-defined color that has an ARGB value of #00FFFFFF.
Public property Static member Turquoise Gets the system-defined color that has an ARGB value of #FF40E0D0.
Public property Static member Violet Gets the system-defined color that has an ARGB value of #FFEE82EE.
Public property Static member Wheat Gets the system-defined color that has an ARGB value of #FFF5DEB3.
Public property Static member White Gets the system-defined color that has an ARGB value of #FFFFFFFF.
Public property Static member WhiteSmoke Gets the system-defined color that has an ARGB value of #FFF5F5F5.
Public property Static member Yellow Gets the system-defined color that has an ARGB value of #FFFFFF00.
Public property Static member YellowGreen Gets the system-defined color that has an ARGB value of #FF9ACD32.
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top

The Windows Presentation Foundation (WPF) color names match the Microsoft .NET Framework version 1.0, Windows Forms, and Microsoft Internet Explorer color names. This representation is based on UNIX X11 named color values.

The following image shows each predefined color, its name, and its hexadecimal value.

Color Table including a color swatch, the color name, and the hexadecimal value

Predefined colors

See the Brush class for a variety of other more complex ways you can color an area, including gradients (LinearGradientBrush, RadialGradientBrush) or images (ImageBrush).

To paint an area with a solid color, you can use a predefined system brush, such as Red or Blue, or you can create a new SolidColorBrush and describe its Color using alpha, red, green, and blue values. In XAML, you may also paint an area with a solid color by using hexidecimal notation.

The following examples uses each of these techniques to paint a Rectangle blue.

Using a Predefined Brush

In the following example uses the predefined brush Blue to paint a rectangle blue.


<Rectangle Width="50" Height="50" Fill="Blue" />



// Create a rectangle and paint it with
// a predefined brush.
Rectangle myPredefinedBrushRectangle = new Rectangle();
myPredefinedBrushRectangle.Width = 50;
myPredefinedBrushRectangle.Height = 50;
myPredefinedBrushRectangle.Fill = Brushes.Blue;


Using Hexadecimal Notation

The next example uses 8-digit hexadecimal notation to paint a rectangle blue.


<!-- Note that the first two characters "FF" of the 8-digit
     value is the alpha which controls the transparency of 
     the color. Therefore, to make a completely transparent
     color (invisible), use "00" for those digits (e.g. #000000FF). -->
<Rectangle Width="50" Height="50" Fill="#FF0000FF" />


Using ARGB Values

The next example creates a SolidColorBrush and describes its Color using the ARGB values for the color blue.


<Rectangle Width="50" Height="50">
  <Rectangle.Fill>
    <SolidColorBrush>
     <SolidColorBrush.Color>

        <!-- Describes the brush's color using
             RGB values. Each value has a range of 0-255.  
             R is for red, G is for green, and B is for blue.
             A is for alpha which controls transparency of the
             color. Therefore, to make a completely transparent
             color (invisible), use a value of 0 for Alpha. -->
        <Color A="255" R="0" G="0" B="255" />
     </SolidColorBrush.Color>
    </SolidColorBrush>
  </Rectangle.Fill>
</Rectangle>



Rectangle myRgbRectangle = new Rectangle();
myRgbRectangle.Width = 50;
myRgbRectangle.Height = 50;
SolidColorBrush mySolidColorBrush = new SolidColorBrush();

// Describes the brush's color using RGB values. 
// Each value has a range of 0-255.
mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
myRgbRectangle.Fill = mySolidColorBrush;           


For other ways of describing color, see the Color structure.

Related Topics

For more information about SolidColorBrush and additional examples, see the Painting with Solid Colors and Gradients Overview overview.

This code example is part of a larger example provided for the SolidColorBrush class. For the complete sample, see the Brushes Sample.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Property List

As a note, you could use the following C# to get the property list:

public IEnumerable<string> GetNames()
{
    BindingFlags binding = BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly;
    PropertyInfo[] properties = typeof(Colors).GetProperties(binding);
    foreach (PropertyInfo property in properties) yield return property.Name;
}

Likewise, the following can be used to get a value:

PropertyInfo property = typeof(Colors).GetProperty(name);
Color color = (Color)property.GetValue(null, null);

I hope this helps.
Scott

I second the color list comment
I want to bind a ComboBox to a list of colors. It would be so convenient to bind the ItemsSource to an enumeration of these colors. I don't need the complex functionality of having a dynamic color picker. Same with the SystemColors, SystemBrushes, etc. types. Guess I'll have to use the list from above... *sigh*
Color list

There needs to be a colors.getcolors() function. For anyone needing this, here is the list:

Public Text_Colors() As String = {"AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque", "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood", "CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk", "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGray", "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "DimGray", "DodgerBlue", "Firebrick", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Gray", "Green", "GreenYellow", "Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender", "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", "LightCyan", "LightGoldenrodYellow", "LightGray", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGray", "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta", "Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple", "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed", "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple", "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "SeaShell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato", "Transparent", "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen"}