Freigeben über


SolidColorBrush.Color Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the color of this SolidColorBrush.

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

Syntax

'Declaration
Public Property Color As Color
public Color Color { get; set; }
<SolidColorBrush Color="predefinedColorName"/>
- or -
<SolidColorBrush Color="#rgb"/>
- or -
<SolidColorBrush Color="#argb"/>
- or -
<SolidColorBrush Color="#rrggbb"/>
- or -
<SolidColorBrush Color="#aarrggbb"/>
- or -
<SolidColorBrush Color="sc#scR,scG,scB"/>
- or -
<SolidColorBrush Color="sc#scA,scR,scG,scB"/>

XAML Values

  • predefinedColorName
    One of the colors predefined by the Colors class (static properties), or one of the other named colors. See Remarks.

  • rgb
    A three-character hexadecimal value. The first character specifies the color's R value, the second character specifies the G value, and the third character specifies the B value. For example, #00F.

  • argb
    A four-character hexadecimal value. The first character specifies the color's A value, the second character specifies its R value, the third character specifies the G value, and the fourth character specifies its B value. For example, #F00F.

  • rrggbb
    A six-character hexadecimal value. The first two characters specify the color's R value, the next two specify its G value, and the final two specify its B value. For example, #0000FF.

  • aarrggbb
    An eight-character hexadecimal value. The first two characters specify the color's A value, the next two specify its R value, the next two specify its G value, and the final two specify its B value. For example, #FF0000FF.

  • scA
    The color's ScA value as a value between 0 and 1. ScA is not exposed as a Color property directly.

  • scR
    The color's ScR value as a value between 0 and 1. ScR is not exposed as a Color property directly.

  • scG
    The color's ScG value as a value between 0 and 1. ScG is not exposed as a Color property directly.

  • scB
    The color's ScB value as a value between 0 and 1. ScB is not exposed as a Color property directly.

Property Value

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

Remarks

Dependency property identifier field: ColorProperty

The Color property of SolidColorBrush uses the same type conversion as the SolidColorBrush class construction behavior, which in turn is forwarded as the default attribute type conversion for all Brush properties. This syntax enables you to specify a string value for a property or attribute that takes a Brush, and the string is interpreted within a number of possible conventions, which include named colors, sRGB, or scRGB.

Predefined Colors

Colors.

Both sRGB and scRGB schemes can specify an alpha value.

For more information on the XAML syntax, see SolidColorBrush, Color and Brush.

If you deliberately set a Transparent value, as opposed to a null value, a Transparent value is hit testable and will intercept mouse actions that you might have intended for objects beneath the transparency. In contrast, a null brush is not hit testable. For most scenarios, a null brush is what you want, not a transparent SolidColorBrush. Most properties that take a Brush value, for example Control.Background, start with a default value of a null brush. The default of Transparent applies only if you actually construct a non-null SolidColorBrush and apply it to an existing Brush property. For more information on hit testing concepts, see Hit Testing and Input Events.

For information on setting Color to a predefined color name rather than an existing value of Color, see "Setting Predefined Colors for a SolidColorBrush in Code" section of SolidColorBrush.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.