This documentation is archived and is not being maintained.

SolidColorBrush.Color Property

Gets or sets the color of this SolidColorBrush.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public Color Color { get; set; }
    <Color .../>
<object Color="Color" .../>

Property Value

Type: System.Windows.Media.Color
The brush's color. The default value is Transparent.

Identifier field


Metadata properties set to true


For a list of predefined colors, see the Colors class. For a list of system colors, see the SystemColors class.

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">

        <!-- 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" />

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.

More Code

How to: Animate the Color or Opacity of a SolidColorBrushThis example shows how to animate the Color and Opacity of a SolidColorBrush.

.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.