Windows apps
Collapse the table of content
Expand the table of content
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.FromArgb Method

Creates a Color structure using the specified sRGB alpha component and color component values.

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

public static Color FromArgb (
	byte a,
	byte r,
	byte g,
	byte b
public static Color FromArgb (
	byte a, 
	byte r, 
	byte g, 
	byte b
public static function FromArgb (
	a : byte, 
	r : byte, 
	g : byte, 
	b : byte
) : Color
You cannot use methods in XAML.



The alpha channel, A, of the new Color structure.


The red channel, R, of the new Color structure.


The green channel, G, of the new Color structure.


The blue channel, B, of the new Color structure..

Return Value

The Color structure created from a, r, g, and b.

The difference between a Color structure created with FromRgb and FromArgb is that FromArgb defines the alpha component while FromRgb uses a default value of 1 for the alpha component.

The alpha channel of a Color structure determines the amount of transparency the Color has. An alpha value of 1 indicates the Color is completely opaque and a value of 0 indicates the Color is completely transparent.

The sRGB components (A, R, G, B) and the ScRGB components (ScA, ScR, ScG, ScB) of the Color structure are synchronized properties. For example, when R, the sRGB red component, is modified the ScRGB red component, ScR, is transformed to the equivalent value.

The following example shows how to use the FromArgb method to create a Color structure.

private Color FromArgbExample()
    // Create a blue color using the FromArgb static method.
    Color myArgbColor = new Color();
    myArgbColor = Color.FromArgb(255, 0, 255, 0);
    return myArgbColor;

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

© 2016 Microsoft