Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Color Structure

 

Describes a color in terms of alpha, red, green, and blue channels.

Namespace:   System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

[TypeConverterAttribute((ColorConverter^::typeid))]
[LocalizabilityAttribute(LocalizationCategory::None, Readability = Readability::Unreadable)]
public value struct Color : IFormattable, IEquatable<Color>

NameDescription
System_CAPS_pubpropertyA

Gets or sets the sRGB alpha channel value of the color.

System_CAPS_pubpropertyB

Gets or sets the sRGB blue channel value of the color.

System_CAPS_pubpropertyColorContext

Gets the International Color Consortium (ICC) or Image Color Management (ICM) color profile of the color.

System_CAPS_pubpropertyG

Gets or sets the sRGB green channel value of the color.

System_CAPS_pubpropertyR

Gets or sets the sRGB red channel value of the color.

System_CAPS_pubpropertyScA

Gets or sets the ScRGB alpha channel value of the color.

System_CAPS_pubpropertyScB

Gets or sets the ScRGB blue channel value of the color.

System_CAPS_pubpropertyScG

Gets or sets the ScRGB green channel value of the color.

System_CAPS_pubpropertyScR

Gets or sets the ScRGB red channel value of the color.

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticAdd(Color, Color)

Adds two Color structures.

System_CAPS_pubmethodSystem_CAPS_staticAreClose(Color, Color)

Compares two Color structures for fuzzy equality.

System_CAPS_pubmethodClamp()

Sets the ScRGB channels of the color to within the gamut of 0 to 1, if they are outside that range.

System_CAPS_pubmethodEquals(Color)

Tests whether the specified Color structure is identical to this color.

System_CAPS_pubmethodSystem_CAPS_staticEquals(Color, Color)

Tests whether two Color structures are identical.

System_CAPS_pubmethodEquals(Object^)

Tests whether the specified object is a Color structure and is equivalent to this color. (Overrides ValueType::Equals(Object^).)

System_CAPS_pubmethodSystem_CAPS_staticFromArgb(Byte, Byte, Byte, Byte)

Creates a new Color structure by using the specified sRGB alpha channel and color channel values.

System_CAPS_pubmethodSystem_CAPS_staticFromAValues(Single, array<Single>^, Uri^)

Creates a new Color structure by using the specified alpha channel, color channel values, and color profile.

System_CAPS_pubmethodSystem_CAPS_staticFromRgb(Byte, Byte, Byte)

Creates a new Color structure by using the specified sRGB color channel values.

System_CAPS_pubmethodSystem_CAPS_staticFromScRgb(Single, Single, Single, Single)

Creates a new Color structure by using the specified ScRGB alpha channel and color channel values.

System_CAPS_pubmethodSystem_CAPS_staticFromValues(array<Single>^, Uri^)

Creates a new Color structure by using the specified color channel values and color profile.

System_CAPS_pubmethodGetHashCode()

Gets a hash code for this Color structure. (Overrides ValueType::GetHashCode().)

System_CAPS_pubmethodGetNativeColorValues()

Gets the color channel values of the color.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticMultiply(Color, Single)

Multiplies the alpha, red, blue, and green channels of the specified Color structure by the specified value.

System_CAPS_pubmethodSystem_CAPS_staticSubtract(Color, Color)

Subtracts a Color structure from a Color structure.

System_CAPS_pubmethodToString()

Creates a string representation of the color using the sRGB channels. (Overrides ValueType::ToString().)

System_CAPS_pubmethodToString(IFormatProvider^)

Creates a string representation of the color by using the sRGB channels and the specified format provider.

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticAddition(Color, Color)

Adds two Color structures.

System_CAPS_puboperatorSystem_CAPS_staticEquality(Color, Color)

Tests whether two Color structures are identical.

System_CAPS_puboperatorSystem_CAPS_staticInequality(Color, Color)

Tests whether two Color structures are not identical.

System_CAPS_puboperatorSystem_CAPS_staticMultiply(Color, Single)

Multiplies the alpha, red, blue, and green channels of the specified Color structure by the specified value.

System_CAPS_puboperatorSystem_CAPS_staticSubtraction(Color, Color)

Subtracts a Color structure from a Color structure.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIFormattable::ToString(String^, IFormatProvider^)

Formats the value of the current instance using the specified format.

<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"/>

predefinedColor

One of the colors predefined by the Colors class.

rgb

A three-digit hexadecimal number. The first digit specifies the color's R value, the second digit specifies the G value, and the third digit specifies the B value. For example, 00F.

argb

A four-digit hexadecimal number. The first digit specifies the color's A value, the second digit specifies its R value, the next digit specifies the G value, and the final digit specifies its B value. For example, F00F.

rrggbb

A six-digit hexadecimal number. The first two digits specify the color's R value, the next two specify its G value, and the final two specify its B value. For example, 0000FF.

aarrggbb

An eight-digit hexadecimal number. The first two digits specify the color's A value, the next two specify its R value, the next two specify its G value, and the final two specify its B value. For example, FF0000FF.

scA

System::Single

The color's ScA value.

scR

System::Single

The color's ScR value.

scG

System::Single

The color's ScG value.

scB

System::Single

The color's ScB value.

profileUri

System::Uri

The International Color Consortium (ICC) or Image Color Management (ICM) color profile.

alphaValue

System::Single

The alpha channel color value. The value range is 0.0 to 1.0.

colorValue

System::Single

A comma-delimited list of three to eight values that represent the color channels of the color profile. The value range is 0.0 to 1.0.

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>

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft