Windows Phone Theme colors

Phone theme colorsWhen developing Windows Phone apps I love to use the theme accent colors in my apps. Since there are some new theme colors in Windows Phone 8 I started searching for their color codes. Lucky me I found them on msdn.

Now you may be thinking how to use the colors in your own Windows Phone apps. The Color object doesn’t contain a color called Emerald. So I created a small class to help me out with this issue. First of all I created a small static helper method to convert the hexa colors to a color object. So we are able to put in the hexa color string and the function returns a color for us.

Then I made some properties that caches the colors for us on their first use. The Color properties looks like this.

So this is the complete class I came up with.

When you want to use it in a MVVM solution you probably want to create a SolidColorBrush to bind your control to. You could use my class like this to make a bindable property for your ViewModel.

I hope you found this article useful. Please fork my gist on Github or past the file in your own project and share it with your friends.

One thought on “Windows Phone Theme colors

  1. Till

    Hi Marco,
    Thx for providing the PhoneThemeColors class, BUT I can“t believe that it works as you implemented it! Color is not a nullable Type, so your check for _mycolor == null will always return false and no color will be initiated to the desired value. Whenever you access a variable of Type Color, that has not been explicitly instanciated (private Color _mycolor;) it will give you a transparent color and not null. Did you try the class on your machine?
    Best
    Till

    Reply

Leave a Reply