Objects that use a brush color

.Foreground

Setting A Brush Color

	MyTextBlock.Foreground = new SolidColorBrush(Colors.White);    //<<<Note its Colors, not Color!

	MyTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xff, 0xff));

Using a const defined color

This is actually quite hard as Color can’t be defined const and .FromArgb can’t take a Int32 in UWP. The following achieves it

	public static readonly byte[] MyConstColor = new byte[] { 0xff, 0xff, 0xff, 0xff };

	MyTextBlock.Foreground = new SolidColorBrush(Color.FromArgb(MyConstColor[0], MyConstColor[1], MyConstColor[2], MyConstColor[3]));
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *