Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Brush Class

Defines objects used to paint graphical objects. Classes that derive from Brush describe how the area is painted.

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

public abstract class Brush : DependencyObject
<object property="predefinedColorName"/>
- or -
<object property="#rgb"/>
- or -
<object property="#argb"/>
- or -
<object property="#rrggbb"/>
- or -
<object property="#aarrggbb"/>
- or -
<object property="sc#scR,scG,scB"/>
- or -
<object property="sc#scA,scR,scG,scB"/>

XAML Values

predefinedColorName

The name of a color. This can either be a static property name of Colors, or one of the color names that are processed directly as strings. See Remarks for a table of predefined colors.

rgb

A three-character hexadecimal value that describes a Color. 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 that describes a Color. 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 that describes a Color. The first two character 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 that describes a Color. 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 ScA value for a Color. Color does not store a specific ScA value, so the provided value will be converted and stored in A.

scR

The ScR value for a Color. Color does not store a specific ScR value, so the provided value will be converted and stored in R.

scG

The ScG value for a Color. Color does not store a specific ScG value, so the provided value will be converted and stored in G.

scB

The ScB value for a Color. Color does not store a specific ScB value, so the provided value will be converted and stored in B.

The Brush type exposes the following members.

  NameDescription
Protected methodSupported by Silverlight for Windows PhoneBrushInitializes a new instance of the Brush class.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertySupported by Silverlight for Windows PhoneOpacityGets or sets the degree of opacity of a Brush.
Public propertySupported by Silverlight for Windows PhoneRelativeTransformGets or sets the transformation that is applied to the brush using relative coordinates.
Public propertySupported by Silverlight for Windows PhoneTransformGets or sets the transformation that is applied to the brush.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetAnimationBaseValueReturns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public fieldStatic memberSupported by Silverlight for Windows PhoneOpacityPropertyIdentifies the Opacity dependency property.
Public fieldStatic memberSupported by Silverlight for Windows PhoneRelativeTransformPropertyIdentifies the RelativeTransform dependency property.
Public fieldStatic memberSupported by Silverlight for Windows PhoneTransformPropertyIdentifies the Transform dependency property.
Top

For XAML syntaxes that take a Brush, you need to specify one of the following:

  • A Color, specified as a string to directly fill a Brush-type property in XAML attribute form. That string is implied to create a SolidColorBrush to fill the value, and the Color you specify becomes the Color property value. This is the syntax shown in the "XAML Attribute Usage" and "XAML Values" sections of this topic.

  • A nonabstract derived type of Brush as an object element, with the Brush-type property in question being specified in property element form. For details, see the XAML syntax on the reference pages for SolidColorBrush, LinearGradientBrush, RadialGradientBrush, ImageBrush, and VideoBrush. It is also possible to derive custom types from Brush.

  • A StaticResource, Binding or TemplateBinding reference to an existing Brush.

For more information and examples of the XAML syntax and illustrations of the types of brushes, see Brushes.

A Brush "paints" an area with its output. Different brushes have different types of output. Some brushes paint an area with a solid color, gradient, or image. The following list describes the different types of brushes:

Predefined Colors

You can paint using a SolidColorBrush that uses a predefined solid color. This can either be a static property name of Colors, or one of another set of color names that are processed directly as strings if specified as a XAML attribute value. See Color or SolidColorBrush for a table of named colors, and instructions on how to specify named colors in code. To use a predefined color, you can use the XAML attribute syntax for any property that takes a Brush, using the named color convention. Or you can create a SolidColorBrush and specify its Color value as a XAML attribute, using the named color convention.

Predefined Colors

Colors.

Brushes in XAML

The following table lists the different Brush types that can be used in XAML and the syntax they support. For detailed syntax information for a specific brush, see that brush's type page.

The XAML Attribute Usage in this topic is specifically the SolidColorBrush attribute syntax. The SolidColorBrush syntax is the default behavior if you specify an attribute value string for any property that expects a Brush type. However, if you use a markup extension such as Binding or StaticResource, you could reference any type of Brush.

Possible XAML Usages of Brush Classes

Class

Attribute Syntax

Object Element Syntax

SolidColorBrush

Yes

Yes

ImageBrush

No

Yes

LinearGradientBrush

No

Yes

RadialGradientBrush

No

Yes

VideoBrush

No

Yes

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

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

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft