Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-paint-an-area-with-a-system-brush.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

3.2 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Paint an Area with a System Brush 03/30/2017
system brushes [WPF], painting with
painting [WPF], with system brushes
brushes [WPF], painting with system brushes [WPF]
5141a763-9235-42cb-a6bb-afc75513eac7

How to: Paint an Area with a System Brush

The xref:System.Windows.SystemColors class provides access to system brushes and colors, such as xref:System.Windows.SystemColors.ControlBrush%2A, xref:System.Windows.SystemColors.ControlBrushKey%2A, and xref:System.Windows.SystemColors.DesktopBrush%2A. A system brush is a xref:System.Windows.Media.SolidColorBrush object that paints an area with the specified system color. A system brush always produces a solid fill; it can't be used to create a gradient.

You can use system brushes as either a static or a dynamic resource. Use a dynamic resource if you want the brush to update automatically if the user changes the system brush as the application is running; otherwise, use a static resource. The SystemColors class contains a variety of static properties that follow a strict naming convention:

A system color is a xref:System.Windows.Media.Color structure that can be used to configure a brush. For example, you can create a gradient using system colors by setting the xref:System.Windows.Media.GradientStop.Color%2A properties of a xref:System.Windows.Media.LinearGradientBrush object's gradient stops with system colors. For an example, see Use System Colors in a Gradient.

Example

The following example uses a dynamic system brush reference to set the Background of a button.

[!code-xamlbrushsamples_snip#GraphicsMMDynamicSystemColorDesktopBrushKeyExampleWholePage]

The next example uses a static system brush reference to set the Background of a button.

[!code-xamlbrushsamples_snip#GraphicsMMStaticSystemColorDesktopBrushExampleWholePage]

For an example showing how to use a system color in a gradient, see Use System Colors in a Gradient.

See also