Defines objects used to paint graphical objects. Classes that derive from Brush describe how the area is painted.
Assembly: System.Windows (in System.Windows.dll)
'Declaration Public MustInherit Class Brush _ Inherits DependencyObject
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"/>
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.
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.
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.
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.
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.
The Brush type exposes the following members.
|Brush||Initializes a new instance of the Brush class.|
|Dispatcher||Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.)|
|Opacity||Gets or sets the degree of opacity of a Brush.|
|RelativeTransform||Gets or sets the transformation that is applied to the brush using relative coordinates.|
|Transform||Gets or sets the transformation that is applied to the brush.|
|CheckAccess||Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)|
|ClearValue||Clears the local value of a dependency property. (Inherited from DependencyObject.)|
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetAnimationBaseValue||Returns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|GetValue||Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ReadLocalValue||Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)|
|SetValue||Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|OpacityProperty||Identifies the Opacity dependency property.|
|RelativeTransformProperty||Identifies the RelativeTransform dependency property.|
|TransformProperty||Identifies the Transform dependency property.|
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.
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:
LinearGradientBrush: Paints an area with a linear gradient.
RadialGradientBrush: Paints an area with a radial gradient.
ImageBrush: Paints an area with an image.
VideoBrush: Paints an area with a running video.
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.
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
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.