Question

I have a class that worked on a previous project i had that looped through all the available colors in the WPF application, this is shown below;

public class ListOfColors
    {
        public List<ComboBoxItem> SelectableColours;
        private PropertyInfo[] _propInfo;
        public List<ComboBoxItem> GetListOfColours()
        {
            List<ComboBoxItem> SelectableColours = new List<ComboBoxItem>();
            Type brushesType = typeof(Brushes);

            PropertyInfo[] colors = brushesType.GetProperties();
            _propInfo = colors;


            foreach (var color in colors)
            {
                ComboBoxItem colour = new ComboBoxItem();
                colour.Content = color.Name;
                SelectableColours.Add(colour);
            }

            return SelectableColours;
        }
    }

This works fine with my WPF application but now i am trying to replicate the same thing in a silverlight project but it is saying im missing a using directive or assembly reference. I have tried to add the System.Windows.Media reference but it still says that im missing it.

Is there a step i am missing or do i have to get a different Type back, I have tried to use the Colors as a type but this brings back a limited number of colors, 15 in total;

Type brushesType = typeof(Colors);
Was it helpful?

Solution

Silverlight does not have a Brushes class, and as you note, the Colors class has a limited number.

I suggest you make your own version of Colors that has everything.

See: http://lotsacode.wordpress.com/2010/02/27/translating-c-color-to-silverlight-color/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top