Created
January 12, 2013 16:36
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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