Brush Brush Brush Class

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

Syntax

Declaration

public class Brushpublic class BrushPublic Class 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 Hierarchy

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 summary

Provides base class initialization behavior for Brush -derived classes.

Properties summary

Gets or sets the degree of opacity of a Brush.

Identifies the Opacity dependency property.

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

Identifies the RelativeTransform dependency property.

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

Identifies the Transform dependency property.

Constructors

  • Brush()
    Brush()
    Brush()
    Brush()

    Provides base class initialization behavior for Brush -derived classes.

    protected Brush()protected New()Protected Sub New()protected 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 doublepublic double Opacity { get; set; }
    <brush Opacity="double"/>
    

    Property 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.

  • 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 DependencyPropertypublic static DependencyProperty OpacityProperty { get; }

    Property Value

  • 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 Transformpublic Transform RelativeTransform { get; set; }
    <brush>
      <brush.RelativeTransform>
        singleTransform
      </brush.RelativeTransform>
    </brush>
    

    Property Value

  • 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 DependencyPropertypublic static DependencyProperty RelativeTransformProperty { get; }

    Property Value

  • 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 Transformpublic Transform Transform { get; set; }
    <brush>
      <brush.Transform>
        singleTransform
      </brush.Transform>
    </brush>
    

    Property Value

  • 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 DependencyPropertypublic static DependencyProperty TransformProperty { get; }

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ComposableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Media.dll