Export (0) Print
Expand All
9 out of 14 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.

  NameDescription
Public propertyStatic memberAliceBlueGets the system-defined color that has an ARGB value of #FFF0F8FF.
Public propertyStatic memberAntiqueWhiteGets the system-defined color that has an ARGB value of #FFFAEBD7.
Public propertyStatic memberAquaGets the system-defined color that has an ARGB value of #FF00FFFF.
Public propertyStatic memberAquamarineGets the system-defined color that has an ARGB value of #FF7FFFD4.
Public propertyStatic memberAzureGets the system-defined color that has an ARGB value of #FFF0FFFF.
Public propertyStatic memberBeigeGets the system-defined color that has an ARGB value of #FFF5F5DC.
Public propertyStatic memberBisqueGets the system-defined color that has an ARGB value of #FFFFE4C4.
Public propertyStatic memberBlackGets the system-defined color that has an ARGB value of #FF000000.
Public propertyStatic memberBlanchedAlmondGets the system-defined color that has an ARGB value of #FFFFEBCD.
Public propertyStatic memberBlueGets the system-defined color that has an ARGB value of #FF0000FF.
Public propertyStatic memberBlueVioletGets the system-defined color that has an ARGB value of #FF8A2BE2.
Public propertyStatic memberBrownGets the system-defined color that has an ARGB value of #FFA52A2A.
Public propertyStatic memberBurlyWoodGets the system-defined color that has an ARGB value of #FFDEB887.
Public propertyStatic memberCadetBlueGets the system-defined color that has an ARGB value of #FF5F9EA0.
Public propertyStatic memberChartreuseGets the system-defined color that has an ARGB value of #FF7FFF00.
Public propertyStatic memberChocolateGets the system-defined color that has an ARGB value of #FFD2691E.
Public propertyStatic memberCoralGets the system-defined color that has an ARGB value of #FFFF7F50.
Public propertyStatic memberCornflowerBlueGets the system-defined color that has an ARGB value of #FF6495ED.
Public propertyStatic memberCornsilkGets the system-defined color that has an ARGB value of #FFFFF8DC.
Public propertyStatic memberCrimsonGets the system-defined color that has an ARGB value of #FFDC143C.
Public propertyStatic memberCyanGets the system-defined color that has an ARGB value of #FF00FFFF.
Public propertyStatic memberDarkBlueGets the system-defined color that has an ARGB value of #FF00008B.
Public propertyStatic memberDarkCyanGets the system-defined color that has an ARGB value of #FF008B8B.
Public propertyStatic memberDarkGoldenrodGets the system-defined color that has an ARGB value of #FFB8860B.
Public propertyStatic memberDarkGrayGets the system-defined color that has an ARGB value of #FFA9A9A9.
Public propertyStatic memberDarkGreenGets the system-defined color that has an ARGB value of #FF006400.
Public propertyStatic memberDarkKhakiGets the system-defined color that has an ARGB value of #FFBDB76B.
Public propertyStatic memberDarkMagentaGets the system-defined color that has an ARGB value of #FF8B008B.
Public propertyStatic memberDarkOliveGreenGets the system-defined color that has an ARGB value of #FF556B2F.
Public propertyStatic memberDarkOrangeGets the system-defined color that has an ARGB value of #FFFF8C00.
Public propertyStatic memberDarkOrchidGets the system-defined color that has an ARGB value of #FF9932CC.
Public propertyStatic memberDarkRedGets the system-defined color that has an ARGB value of #FF8B0000.
Public propertyStatic memberDarkSalmonGets the system-defined color that has an ARGB value of #FFE9967A.
Public propertyStatic memberDarkSeaGreenGets the system-defined color that has an ARGB value of #FF8FBC8F.
Public propertyStatic memberDarkSlateBlueGets the system-defined color that has an ARGB value of #FF483D8B.
Public propertyStatic memberDarkSlateGrayGets the system-defined color that has an ARGB value of #FF2F4F4F.
Public propertyStatic memberDarkTurquoiseGets the system-defined color that has an ARGB value of #FF00CED1.
Public propertyStatic memberDarkVioletGets the system-defined color that has an ARGB value of #FF9400D3.
Public propertyStatic memberDeepPinkGets the system-defined color that has an ARGB value of #FFFF1493.
Public propertyStatic memberDeepSkyBlueGets the system-defined color that has an ARGB value of #FF00BFFF.
Public propertyStatic memberDimGrayGets the system-defined color that has an ARGB value of #FF696969.
Public propertyStatic memberDodgerBlueGets the system-defined color that has an ARGB value of #FF1E90FF.
Public propertyStatic memberFirebrickGets the system-defined color that has an ARGB value of #FFB22222.
Public propertyStatic memberFloralWhiteGets the system-defined color that has an ARGB value of #FFFFFAF0.
Public propertyStatic memberForestGreenGets the system-defined color that has an ARGB value of #FF228B22.
Public propertyStatic memberFuchsiaGets the system-defined color that has an ARGB value of #FFFF00FF.
Public propertyStatic memberGainsboroGets the system-defined color that has an ARGB value of #FFDCDCDC.
Public propertyStatic memberGhostWhiteGets the system-defined color that has an ARGB value of #FFF8F8FF.
Public propertyStatic memberGoldGets the system-defined color that has an ARGB value of #FFFFD700.
Public propertyStatic memberGoldenrodGets the system-defined color that has an ARGB value of #FFDAA520.
Public propertyStatic memberGrayGets the system-defined color that has an ARGB value of #FF808080.
Public propertyStatic memberGreenGets the system-defined color that has an ARGB value of #FF008000.
Public propertyStatic memberGreenYellowGets the system-defined color that has an ARGB value of #FFADFF2F.
Public propertyStatic memberHoneydewGets the system-defined color that has an ARGB value of #FFF0FFF0.
Public propertyStatic memberHotPinkGets the system-defined color that has an ARGB value of #FFFF69B4.
Public propertyStatic memberIndianRedGets the system-defined color that has an ARGB value of #FFCD5C5C.
Public propertyStatic memberIndigoGets the system-defined color that has an ARGB value of #FF4B0082.
Public propertyStatic memberIvoryGets the system-defined color that has an ARGB value of #FFFFFFF0.
Public propertyStatic memberKhakiGets the system-defined color that has an ARGB value of #FFF0E68C.
Public propertyStatic memberLavenderGets the system-defined color that has an ARGB value of #FFE6E6FA.
Public propertyStatic memberLavenderBlushGets the system-defined color that has an ARGB value of #FFFFF0F5.
Public propertyStatic memberLawnGreenGets the system-defined color that has an ARGB value of #FF7CFC00.
Public propertyStatic memberLemonChiffonGets the system-defined color that has an ARGB value of #FFFFFACD.
Public propertyStatic memberLightBlueGets the system-defined color that has an ARGB value of #FFADD8E6.
Public propertyStatic memberLightCoralGets the system-defined color that has an ARGB value of #FFF08080.
Public propertyStatic memberLightCyanGets the system-defined color that has an ARGB value of #FFE0FFFF.
Public propertyStatic memberLightGoldenrodYellowGets the system-defined color that has an ARGB value of #FFFAFAD2.
Public propertyStatic memberLightGrayGets the system-defined color that has an ARGB value of #FFD3D3D3.
Public propertyStatic memberLightGreenGets the system-defined color that has an ARGB value of #FF90EE90.
Public propertyStatic memberLightPinkGets the system-defined color that has an ARGB value of #FFFFB6C1.
Public propertyStatic memberLightSalmonGets the system-defined color that has an ARGB value of #FFFFA07A.
Public propertyStatic memberLightSeaGreenGets the system-defined color that has an ARGB value of #FF20B2AA.
Public propertyStatic memberLightSkyBlueGets the system-defined color that has an ARGB value of #FF87CEFA.
Public propertyStatic memberLightSlateGrayGets the system-defined color that has an ARGB value of #FF778899.
Public propertyStatic memberLightSteelBlueGets the system-defined color that has an ARGB value of #FFB0C4DE.
Public propertyStatic memberLightYellowGets the system-defined color that has an ARGB value of #FFFFFFE0.
Public propertyStatic memberLimeGets the system-defined color that has an ARGB value of #FF00FF00.
Public propertyStatic memberLimeGreenGets the system-defined color that has an ARGB value of #FF32CD32.
Public propertyStatic memberLinenGets the system-defined color that has an ARGB value of #FFFAF0E6.
Public propertyStatic memberMagentaGets the system-defined color that has an ARGB value of #FFFF00FF.
Public propertyStatic memberMaroonGets the system-defined color that has an ARGB value of #FF800000.
Public propertyStatic memberMediumAquamarineGets the system-defined color that has an ARGB value of #FF66CDAA.
Public propertyStatic memberMediumBlueGets the system-defined color that has an ARGB value of #FF0000CD.
Public propertyStatic memberMediumOrchidGets the system-defined color that has an ARGB value of #FFBA55D3.
Public propertyStatic memberMediumPurpleGets the system-defined color that has an ARGB value of #FF9370DB.
Public propertyStatic memberMediumSeaGreenGets the system-defined color that has an ARGB value of #FF3CB371.
Public propertyStatic memberMediumSlateBlueGets the system-defined color that has an ARGB value of #FF7B68EE.
Public propertyStatic memberMediumSpringGreenGets the system-defined color that has an ARGB value of #FF00FA9A.
Public propertyStatic memberMediumTurquoiseGets the system-defined color that has an ARGB value of #FF48D1CC.
Public propertyStatic memberMediumVioletRedGets the system-defined color that has an ARGB value of #FFC71585.
Public propertyStatic memberMidnightBlueGets the system-defined color that has an ARGB value of #FF191970.
Public propertyStatic memberMintCreamGets the system-defined color that has an ARGB value of #FFF5FFFA.
Public propertyStatic memberMistyRoseGets the system-defined color that has an ARGB value of #FFFFE4E1.
Public propertyStatic memberMoccasinGets the system-defined color that has an ARGB value of #FFFFE4B5.
Public propertyStatic memberNavajoWhiteGets the system-defined color that has an ARGB value of #FFFFDEAD.
Public propertyStatic memberNavyGets the system-defined color that has an ARGB value of #FF000080.
Public propertyStatic memberOldLaceGets the system-defined color that has an ARGB value of #FFFDF5E6.
Public propertyStatic memberOliveGets the system-defined color that has an ARGB value of #FF808000.
Public propertyStatic memberOliveDrabGets the system-defined color that has an ARGB value of #FF6B8E23.
Public propertyStatic memberOrangeGets the system-defined color that has an ARGB value of #FFFFA500.
Public propertyStatic memberOrangeRedGets the system-defined color that has an ARGB value of #FFFF4500.
Public propertyStatic memberOrchidGets the system-defined color that has an ARGB value of #FFDA70D6.
Public propertyStatic memberPaleGoldenrodGets the system-defined color that has an ARGB value of #FFEEE8AA.
Public propertyStatic memberPaleGreenGets the system-defined color that has an ARGB value of #FF98FB98.
Public propertyStatic memberPaleTurquoiseGets the system-defined color that has an ARGB value of #FFAFEEEE.
Public propertyStatic memberPaleVioletRedGets the system-defined color that has an ARGB value of #FFDB7093.
Public propertyStatic memberPapayaWhipGets the system-defined color that has an ARGB value of #FFFFEFD5.
Public propertyStatic memberPeachPuffGets the system-defined color that has an ARGB value of #FFFFDAB9.
Public propertyStatic memberPeruGets the system-defined color that has an ARGB value of #FFCD853F.
Public propertyStatic memberPinkGets the system-defined color that has an ARGB value of #FFFFC0CB.
Public propertyStatic memberPlumGets the system-defined color that has an ARGB value of #FFDDA0DD.
Public propertyStatic memberPowderBlueGets the system-defined color that has an ARGB value of #FFB0E0E6.
Public propertyStatic memberPurpleGets the system-defined color that has an ARGB value of #FF800080.
Public propertyStatic memberRedGets the system-defined color that has an ARGB value of #FFFF0000.
Public propertyStatic memberRosyBrownGets the system-defined color that has an ARGB value of #FFBC8F8F.
Public propertyStatic memberRoyalBlueGets the system-defined color that has an ARGB value of #FF4169E1.
Public propertyStatic memberSaddleBrownGets the system-defined color that has an ARGB value of #FF8B4513.
Public propertyStatic memberSalmonGets the system-defined color that has an ARGB value of #FFFA8072.
Public propertyStatic memberSandyBrownGets the system-defined color that has an ARGB value of #FFF4A460.
Public propertyStatic memberSeaGreenGets the system-defined color that has an ARGB value of #FF2E8B57.
Public propertyStatic memberSeaShellGets the system-defined color that has an ARGB value of #FFFFF5EE.
Public propertyStatic memberSiennaGets the system-defined color that has an ARGB value of #FFA0522D.
Public propertyStatic memberSilverGets the system-defined color that has an ARGB value of #FFC0C0C0.
Public propertyStatic memberSkyBlueGets the system-defined color that has an ARGB value of #FF87CEEB.
Public propertyStatic memberSlateBlueGets the system-defined color that has an ARGB value of #FF6A5ACD.
Public propertyStatic memberSlateGrayGets the system-defined color that has an ARGB value of #FF708090.
Public propertyStatic memberSnowGets the system-defined color that has an ARGB value of #FFFFFAFA.
Public propertyStatic memberSpringGreenGets the system-defined color that has an ARGB value of #FF00FF7F.
Public propertyStatic memberSteelBlueGets the system-defined color that has an ARGB value of #FF4682B4.
Public propertyStatic memberTanGets the system-defined color that has an ARGB value of #FFD2B48C.
Public propertyStatic memberTealGets the system-defined color that has an ARGB value of #FF008080.
Public propertyStatic memberThistleGets the system-defined color that has an ARGB value of #FFD8BFD8.
Public propertyStatic memberTomatoGets the system-defined color that has an ARGB value of #FFFF6347.
Public propertyStatic memberTransparentGets the system-defined color that has an ARGB value of #00FFFFFF.
Public propertyStatic memberTurquoiseGets the system-defined color that has an ARGB value of #FF40E0D0.
Public propertyStatic memberVioletGets the system-defined color that has an ARGB value of #FFEE82EE.
Public propertyStatic memberWheatGets the system-defined color that has an ARGB value of #FFF5DEB3.
Public propertyStatic memberWhiteGets the system-defined color that has an ARGB value of #FFFFFFFF.
Public propertyStatic memberWhiteSmokeGets the system-defined color that has an ARGB value of #FFF5F5F5.
Public propertyStatic memberYellowGets the system-defined color that has an ARGB value of #FFFFFF00.
Public propertyStatic memberYellowGreenGets the system-defined color that has an ARGB value of #FF9ACD32.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns 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.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.