Convert Hex String to .NET Color(十六进制字符串颜色转Color)

string xCol = "#FF00DD";
Color c = System.Drawing.ColorTranslator.FromHtml(xCol);

 或者

    #region 十六进制string 颜色转换为Color
        public static Color ToColor(this string value)
        {
            value = value.Replace("#", "");
            Int32 v = Int32.Parse(value, System.Globalization.NumberStyles.HexNumber);
            return new Color
            {
                A = 255,
                R = Convert.ToByte((v >> 16) & 255),
                G = Convert.ToByte((v >> 8) & 255),
                B = Convert.ToByte((v >> 0) & 255),
            };
        }
        #endregion

 

你可能感兴趣的:(silverlight)