Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 3.48 KB

brush.md

File metadata and controls

64 lines (45 loc) · 3.48 KB
-api-id -api-type
T:Windows.UI.Xaml.Media.Brush
winrt class

Windows.UI.Xaml.Media.Brush

-description

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

-xaml-syntax

<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"/>

-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:

Version history

Windows version SDK version Value added
1809 17763 PopulatePropertyInfo
1809 17763 PopulatePropertyInfoOverride

-examples

-see-also

DependencyObject, SolidColorBrush, Color, Colors, Use brushes, Image and ImageBrush, ResourceDictionary and XAML resource references