Contains system colors, system brushes, and system resource keys that correspond to system display elements.
Namespace:
System.Windows
Assembly:
PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Visual Basic (Declaration)
Public NotInheritable Class SystemColors
You do not need to declare an instance of a static class in order to access its members.
public static class SystemColors
public ref class SystemColors abstract sealed
public final class SystemColors
You cannot declare this managed class in XAML, but you can use its static properties to assign values in XAML.
The SystemColors class provides access to system brushes and colors, such as ControlBrush, ControlBrushKey, and DesktopBrush. A system brush is a 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 SolidColorBrush of the specified system color.
<SystemColor>BrushKey
Gets a dynamic reference to a SolidColorBrush of the specified system color.
<SystemColor>Color
Gets a static reference to a Color structure of the specified system color.
<SystemColor>ColorKey
Gets a dynamic reference to the Color structure of the specified system color.
A system color is a Color structure that can be used to configure a brush. For example, you can create a gradient using system colors by setting the Color properties of a LinearGradientBrush object's gradient stops with system colors. For an example, see How to: Use System Colors in a Gradient.
The following example uses a dynamic system brush reference to set the Background of a button.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="SystemColors Example" Background="White">
<StackPanel Margin="20">
<!-- Uses a dynamic resource to set the
background of a button.
If the desktop brush changes while this application
is running, this button will be updated. -->
<Button
Background="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}"
Content="Hello, World!" />
</StackPanel>
</Page>
The next example uses a static system brush reference to set the Background of a button.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="SystemColors Example" Background="White">
<StackPanel Margin="20">
<!-- Uses a static brush to set the
background of a button.
If the desktop brush changes while this application
is running, this button will not be updated until
the page is loaded again. -->
<Button
Background="{x:Static SystemColors.DesktopBrush}"
Content="Hello, World!" />
</StackPanel>
</Page>
For an example showing how to use a system color in a gradient, see How to: Use System Colors in a Gradient.
More Code
| How to: Use System Colors in a Gradient |
To use a system color in a gradient, you use the <SystemColor>Color and <SystemColor>ColorKey static properties of the SystemColors class to obtain a reference to the color, where <SystemColor> is the name of the desired system color. Use the <SystemColor>ColorKey properties when you want to create a dynamic reference that updates automatically as the system theme changes. Otherwise, use the <SystemColor>Color properties.
|
System..::.Object
System.Windows..::.SystemColors
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0
Reference