I want to set Border background color from web color value in my windows 8 mobile application .
I found one method that convert hex to Argb but its not working for me ..
private System.Windows.Media.Color FromHex(string hex)
{
string colorcode = hex;
int argb = Int32.Parse(colorcode.Replace("#", ""), System.Globalization.NumberStyles.HexNumber);
return System.Windows.Media.Color.FromArgb((byte)((argb & -16777216) >> 0x18),
(byte)((argb & 0xff0000) >> 0x10),
(byte)((argb & 0xff00) >> 8),
(byte)(argb & 0xff));
}
I am using above method like..
Border borderCell = new Border();
var col = FromHex("#DD4AA3");
var color =new System.Windows.Media.SolidColorBrush(col);
borderCell.Background = color;
But if I pass color hex value like below
var col = FromHex("#FFEEDDCC");
its works fine but it not work on my hex color value.
Before posting this question I go thru this stack answer. How to get Color from Hexadecimal color code using .NET?