Brush 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, IBrush
public class Brush : DependencyObject, IBrush
Public Class Brush Inherits DependencyObject Implements IBrush
var brush = new brush();
<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)

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() Brush()

Provides base class initialization behavior for Brush -derived classes.

protected : Brush()
protected Brush()
Protected Sub New()
var brush = new brush();

Properties

Opacity 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
var double = brush.opacity;
brush.opacity = double;
<brush Opacity="double"/>
Value
double 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.

OpacityProperty 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
var dependencyProperty = Windows.UI.Xaml.Media.Brush.opacityProperty;

RelativeTransform 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
var transform = brush.relativeTransform;
brush.relativeTransform = transform;
<brush>
  <brush.RelativeTransform>
    singleTransform
  </brush.RelativeTransform>
</brush>
Value
Transform Transform Transform Transform

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

RelativeTransformProperty 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
var dependencyProperty = Windows.UI.Xaml.Media.Brush.relativeTransformProperty;

Transform 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
var transform = brush.transform;
brush.transform = transform;
<brush>
  <brush.Transform>
    singleTransform
  </brush.Transform>
</brush>
Value
Transform Transform Transform Transform

The transformation to apply to the brush.

TransformProperty 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
var dependencyProperty = Windows.UI.Xaml.Media.Brush.transformProperty;

Dispatcher Dispatcher Dispatcher Dispatcher

Inherited from DependencyObject

Methods

ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty) ClearValue(DependencyProperty)

Inherited from DependencyObject

GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty) GetAnimationBaseValue(DependencyProperty)

Inherited from DependencyObject

GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty) GetValue(DependencyProperty)

Inherited from DependencyObject

ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty) ReadLocalValue(DependencyProperty)

Inherited from DependencyObject

RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback) RegisterPropertyChangedCallback(DependencyProperty,DependencyPropertyChangedCallback)

Inherited from DependencyObject

SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object) SetValue(DependencyProperty,Object)

Inherited from DependencyObject

UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64) UnregisterPropertyChangedCallback(DependencyProperty,Int64)

Inherited from DependencyObject

See Also