Color Structure
.NET Framework 4.5
Describes a color in terms of alpha, red, green, and blue channels.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[TypeConverterAttribute(typeof(ColorConverter))] [LocalizabilityAttribute(LocalizationCategory.None, Readability = Readability.Unreadable)] public struct Color : IFormattable, IEquatable<Color>
<Color .../>
<object property="predefinedColor"/> - or - <object property="#rgb"/> - or - <object property="#argb"/> - or - <object property="#rrggbb"/> - or - <object property="#aarrggbb"/> - or - <object property="sc# scA,scR,scG,scB"/> - or - <object property="ContextColor profileUri alphaValue,colorValue"/>
XAML Values
The Color type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | A | Gets or sets the sRGB alpha channel value of the color. |
![]() | B | Gets or sets the sRGB blue channel value of the color. |
![]() | ColorContext | Gets the International Color Consortium (ICC) or Image Color Management (ICM) color profile of the color. |
![]() | G | Gets or sets the sRGB green channel value of the color. |
![]() | R | Gets or sets the sRGB red channel value of the color. |
![]() | ScA | Gets or sets the ScRGB alpha channel value of the color. |
![]() | ScB | Gets or sets the ScRGB blue channel value of the color. |
![]() | ScG | Gets or sets the ScRGB green channel value of the color. |
![]() | ScR | Gets or sets the ScRGB red channel value of the color. |
| Name | Description | |
|---|---|---|
![]() ![]() | Add | Adds two Color structures. |
![]() ![]() | AreClose | Compares two Color structures for fuzzy equality. |
![]() | Clamp | Sets the ScRGB channels of the color to within the gamut of 0 to 1, if they are outside that range. |
![]() | Equals(Color) | Tests whether the specified Color structure is identical to the current color. |
![]() | Equals(Object) | Tests whether the specified object is a Color structure and is equivalent to the current color. (Overrides ValueType.Equals(Object).) |
![]() ![]() | Equals(Color, Color) | Tests whether two Color structures are identical. |
![]() ![]() | FromArgb | Creates a new Color structure by using the specified sRGB alpha channel and color channel values. |
![]() ![]() | FromAValues | Creates a new Color structure by using the specified alpha channel, color channel values, and color profile. |
![]() ![]() | FromRgb | Creates a new Color structure by using the specified sRGB color channel values. |
![]() ![]() | FromScRgb | Creates a new Color structure by using the specified ScRGB alpha channel and color channel values. |
![]() ![]() | FromValues | Creates a new Color structure by using the specified color channel values and color profile. |
![]() | GetHashCode | Gets a hash code for the current Color structure. (Overrides ValueType.GetHashCode().) |
![]() | GetNativeColorValues | Gets the color channel values of the color. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | Multiply | Multiplies the alpha, red, blue, and green channels of the specified Color structure by the specified value. |
![]() ![]() | Subtract | Subtracts a Color structure from a Color structure. |
![]() | ToString() | Creates a string representation of the color using the ScRGB channels. (Overrides ValueType.ToString().) |
![]() | ToString(IFormatProvider) | Creates a string representation of the color by using the ScRGB channels and the specified format provider. |
| Name | Description | |
|---|---|---|
![]() ![]() | Addition | Adds two Color structures. |
![]() ![]() | Equality | Tests whether two Color structures are identical. |
![]() ![]() | Inequality | Tests whether two Color structures are not identical. |
![]() ![]() | Multiply | Multiplies the alpha, red, blue, and green channels of the specified Color structure by the specified value. |
![]() ![]() | Subtraction | Subtracts a Color structure from a Color structure. |
| Name | Description | |
|---|---|---|
![]() ![]() | IFormattable.ToString | Formats the value of the current instance using the specified format. |
This example shows how to use sRGB, ScRGB, and color profile values to create the color blue.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <StackPanel Margin="20"> <!-- This rectangle fill uses a Color with ScRGB values to create a completely opaque blue. --> <Rectangle Width="50" Height="50" Margin="10"> <Rectangle.Fill> <SolidColorBrush> <SolidColorBrush.Color> <!-- Describes the brush's color using ScRGB values. Each value has a range of 0-1. --> <Color ScA="1.0" ScR="0.0" ScG="0.0" ScB="1.0" /> </SolidColorBrush.Color> </SolidColorBrush> </Rectangle.Fill> </Rectangle> <!-- This rectangle fill uses a Color with sRGB values to create a completely opaque blue. --> <Rectangle Width="50" Height="50" Margin="10"> <Rectangle.Fill> <SolidColorBrush> <SolidColorBrush.Color> <!-- Describes the brush's color using sRGB values. Each value is a byte with range of 0-255. --> <Color A="255" R="0" G="0" B="255" /> </SolidColorBrush.Color> </SolidColorBrush> </Rectangle.Fill> </Rectangle> <!-- This rectangle fill uses the sRGB color profile and values to create a complete opaque blue. --> <Rectangle Width="50" Height="50" Margin="10"> <Rectangle.Fill> <SolidColorBrush Color="ContextColor file://C:/WINDOWS/system32/spool/drivers/color/sRGB%20Color%20Space%20Profile.icm 1.0,0.0,0.0,1.0"/> </Rectangle.Fill> </Rectangle> </StackPanel> </Page>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
