Brush Brush Brush Class

Definition

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

public : class Brush : DependencyObject, IBrushpublic class Brush : DependencyObject, IBrushPublic Class Brush Inherits DependencyObject Implements IBrush
<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"/>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited methods

Inherited properties

Remarks

For examples and further explanation of the UI drawing concepts represented by Brush, see Use brushes.

Brushes as XAML resources

Each of the Brush types that can be declared in XAML (SolidColorBrush, LinearGradientBrush, ImageBrush ) is intended to be defined as a resource, so that you can reuse that brush as a resource throughout your app. The XAML syntax shown for Brush types is appropriate for defining the brush as a resource. When you declare a brush as a resource, you also need an x:Key attribute that you'll later use to refer to that resource from other UI definitions. For more info on XAML resources and how to use x:Key attribute, see ResourceDictionary and XAML resource references.

The advantage of declaring brushes as resources is that it reduces the number of runtime objects that are needed to construct a UI: the brush is now shared as a common resource that's providing values for multiple parts of the object graph.

If you look at the existing control template definitions for Windows Runtime XAML controls, you'll see that the templates use brush resources extensively. Many of these resources are system resources, and they use the {ThemeResource} markup extension for the resource reference rather than {StaticResource} markup extension. For more info on how to use system resource brushes in your own control template XAML, see XAML theme resources.

Brush derived classes

Brush is the parent class for several derived classes that either implement practical brushes that paint UI regions, or are intermediate base classes for such brushes:

Constructors

Brush() Brush() Brush()

Provides base class initialization behavior for Brush -derived classes.

protected : Brush()protected Brush()Protected Sub New()
Attributes

Properties

Opacity Opacity Opacity

Gets or sets the degree of opacity of a Brush.

public : double Opacity { get; set; }public double Opacity { get; set; }Public ReadWrite Property Opacity As double
<brush Opacity="double"/>
Value
double double double

The value of the Opacity property is expressed as a value between 0 and 1.0. The default value is 1.0, which is full opacity. 0 is transparent opacity.

Attributes

OpacityProperty OpacityProperty OpacityProperty

Identifies the Opacity dependency property.

public : static DependencyProperty OpacityProperty { get; }public static DependencyProperty OpacityProperty { get; }Public Static ReadOnly Property OpacityProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The Opacity dependency property identifier.

Attributes

RelativeTransform RelativeTransform RelativeTransform

Gets or sets the transformation that is applied to the brush using relative coordinates.

public : Transform RelativeTransform { get; set; }public Transform RelativeTransform { get; set; }Public ReadWrite Property RelativeTransform As Transform
<brush>
  <brush.RelativeTransform>
    singleTransform
  </brush.RelativeTransform>
</brush>
Value
Transform Transform Transform

The transformation that is applied to the brush using relative coordinates. The default value is null.

Attributes

RelativeTransformProperty RelativeTransformProperty RelativeTransformProperty

Identifies the RelativeTransform dependency property.

public : static DependencyProperty RelativeTransformProperty { get; }public static DependencyProperty RelativeTransformProperty { get; }Public Static ReadOnly Property RelativeTransformProperty As DependencyProperty
Attributes

Transform Transform Transform

Gets or sets the transformation that is applied to the brush.

public : Transform Transform { get; set; }public Transform Transform { get; set; }Public ReadWrite Property Transform As Transform
<brush>
  <brush.Transform>
    singleTransform
  </brush.Transform>
</brush>
Value
Transform Transform Transform

The transformation to apply to the brush.

Attributes

TransformProperty TransformProperty TransformProperty

Identifies the Transform dependency property.

public : static DependencyProperty TransformProperty { get; }public static DependencyProperty TransformProperty { get; }Public Static ReadOnly Property TransformProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The Transform dependency property identifier.

Attributes

See Also