Skip to content

Instantly share code, notes, and snippets.

@tanaka-takayoshi
Created January 12, 2013 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanaka-takayoshi/4519110 to your computer and use it in GitHub Desktop.
Save tanaka-takayoshi/4519110 to your computer and use it in GitHub Desktop.
List all the colors defined as public static properties in Colors class and your phone's accent color. ColorViewModel is my defined class.
var colors = new List<ColorViewModel>();
var accentColor = (Color)Resources["PhoneAccentColor"];
colors.Add(new ColorViewModel("Accent Color", accentColor));
colors.AddRange(
typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public)
.Where(p => p.PropertyType == typeof(Color))
.Where(p => p.Name != "Transperant" && p.Name != "Black" )
.Select(p => new ColorViewModel(p.Name, (Color)p.GetValue(typeof(Colors), null))));
public class ColorViewModel
{
public ColorViewModel(string text, Color color)
{
this.Text = text;
this.Color = color;
this.ColorBrush = new SolidColorBrush(color);
}
public string Text { get; set; }
public Color Color { get; set; }
public Brush ColorBrush { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment