ExtensionMethod.NET Home of 818 C#, Visual Basic, F# and Javascript extension methods

ToSolidColorBrush

Converts a uint (0xFFb2b2b2) to a Silverlight SolidColorBrush object.

Source

public static Color ToColor(this uint argb)
{
    return Color.FromArgb((byte)((argb & -16777216) >> 0x18),
                            (byte)((argb & 0xff0000) >> 0x10),
                            (byte)((argb & 0xff00) >> 8),
                            (byte)(argb & 0xff));
}
public static SolidColorBrush ToSolidColorBrush(this uint argb)
{
    return new SolidColorBrush(argb.ToColor());
}

Example

MyRectangle.Fill = 0xFFb2b2b2.ToSolidColorBrush();

Author: Loek van den Ouweland

Submitted on: 21 mei 2010

Language: C#

Type: System.uint

Views: 3076