Conversion Archive

C# – Getting a list of every ‘color’ from System.Drawing or System.Windows.Media

In C# there are two colour structures in existence for making easy reference to a number of colours without the need to use RGB or Hex codes. However, they tend to be accessible only by typing their name – there isn’t an easy way to simply obtain a random colour from these structures. But if

C# WPF – Convert colour to brush for UI styling

Something that may be occasionally frustrating is trying to quickly colour a UI element on a WPF window programmatically when you know the colour code, or maybe even have a ‘color’ variable storing the colour for you. There can be various ways to do this depending on how you have your colour stored, so this