How can I get list of all colors I can pick in Visual Studio Designer (which is System.Windows.Media.Colors
, but that isn\'t a collection) and put them into my
Here's how to do it in code using reflection. The following will dump all predefined WPF color names to Output:
using System.Reflection;
void ListAllColors()
{
Type colorsType = typeof(System.Windows.Media.Colors);
PropertyInfo[] colorsTypePropertyInfos = colorsType.GetProperties(BindingFlags.Public | BindingFlags.Static);
foreach (PropertyInfo colorsTypePropertyInfo in colorsTypePropertyInfos)
Debug.WriteLine(colorsTypePropertyInfo.Name);
}
And to put them in a combobox, you could simply change the last line to:
_comboBox.Items.Add(colorsTypePropertyInfo.Name);