* 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
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 |
|
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:
-
*<SystemColor>*Brush
Gets a static reference to a xref:System.Windows.Media.SolidColorBrush of the specified system color.
-
*<SystemColor>*BrushKey
Gets a dynamic reference to a xref:System.Windows.Media.SolidColorBrush of the specified system color.
-
*<SystemColor>*Color
Gets a static reference to a xref:System.Windows.Media.Color structure of the specified system color.
-
*<SystemColor>*ColorKey
Gets a dynamic reference to the xref:System.Windows.Media.Color structure of the specified system color.
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.