Export (0) Print
Expand All
Expand Minimize

SystemColors.ControlTextBrushKey Property

Gets the ResourceKey for the SolidColorBrush that paints text in three-dimensional display elements.

Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public static ResourceKey ControlTextBrushKey { get; }
/** @property */
public static ResourceKey get_ControlTextBrushKey ()

public static function get ControlTextBrushKey () : ResourceKey

<object property="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
 x:Static  The x:Static Markup Extension. 

Property Value

The resource key for the SolidColorBrush that paints text in three-dimensional display elements. This brush's IsFrozen property is true, so it cannot be modified.

Use the ControlTextBrushKey to create a dynamic reference to the system brush that paints text in three-dimensional display elements. This dynamic reference will automatically update if the brush is changed. To create a static reference that won't update automatically, use ControlTextBrush.

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 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 Use System Colors in a Gradient.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft