Skip to content

Instantly share code, notes, and snippets.

@kiichi
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save kiichi/1759d3382bbcf89fcc48 to your computer and use it in GitHub Desktop.

Select an option

Save kiichi/1759d3382bbcf89fcc48 to your computer and use it in GitHub Desktop.
I could not find BrushConverter class in the latest Universal Windows App namespaces. Here is simple example to convert Hex string to Color class.
//using Windows.UI
class ColorUtil {
// ColorUtil.FromHex("#FFAABBCC")
public static Color FromHex(string hexStr) {
hexStr = hexStr.Replace("#", "");
return Color.FromArgb(
(byte)Convert.ToInt32(hexStr.Substring(0, 2), 16),
(byte)Convert.ToInt32(hexStr.Substring(2, 2), 16),
(byte)Convert.ToInt32(hexStr.Substring(4, 2), 16),
(byte)Convert.ToInt32(hexStr.Substring(6, 2), 16));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment