microsoft xamarin heros c# iOS Android UWP

To set the background color of an object in .NET XAML, you will need to set the Brush object type. To create a Brush object from a hexadecimal color code, use the following.

//input ex: #dcdcdc
public static Windows.UI.Xaml.Media.SolidColorBrush 
        GetColorFromHex(string hexaColor)
	return new Windows.UI.Xaml.Media.SolidColorBrush(
			Convert.ToByte(hexaColor.Substring(1, 2), 16),
			Convert.ToByte(hexaColor.Substring(3, 2), 16),
			Convert.ToByte(hexaColor.Substring(5, 2), 16)

Happy coding!

By Enrico

My greatest passion is technology. I am interested in multiple fields and I have a lot of experience in software design and development. I started professional development when I was 6 years. Today I am a strong full-stack .NET developer (C#, Xamarin, Azure)

This site uses Akismet to reduce spam. Learn how your comment data is processed.