ColorHelper.FromArgb(Byte, Byte, Byte, Byte) Method

Definition

Generates a Color structure, based on discrete Byte values for ARGB components. C# and Microsoft Visual Basic code should use Color.FromArgb instead.

C#
public static Color FromArgb(byte a, byte r, byte g, byte b);

Parameters

a
Byte

The A (transparency) component of the desired color. Range is 0-255.

r
Byte

The R component of the desired color. Range is 0-255.

g
Byte

The G component of the desired color. Range is 0-255.

b
Byte

The B component of the desired color. Range is 0-255.

Returns

The generated Color value.

Examples

This example shows how to create a Color.

C++/WinRT
Windows::UI::Color orangeColor{ Windows::UI::ColorHelper::FromArgb(255, 255, 128, 0) };

This example shows how to create a SolidColorBrush with the specified Color.

C++/WinRT
Windows::UI::Xaml::Media::SolidColorBrush greenBrush{
    Windows::UI::ColorHelper::FromArgb(255, 90, 200, 90) };

Remarks

C#/Visual Basic The ColorHelper class is available for use from C# and Visual Basic code but it's not commonly used. The FromArgb method that's available as a static method of the Color structure has exactly the same functionality, and you also have other API there that's more convenient to use from Color itself rather than using the ColorHelper class. ColorHelper is mainly intended for C++ code, which doesn't have access to the nondata API of the Color structure.

The most common reason for creating a Color value is to use it as an argument for the SolidColorBrush constructor, then assign that brush to a XAML UI property.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also