Second Stanza

May 2, 2009

Silverlight Color Picker Control

Filed under: Silverlight — Tags: — dfbaskin @ 2:21 pm

I’m not sure why a color picker was not included in Silverlight since it seems like such a common control. However, I needed one so I took a look at my options. Plenty of examples exist so I decided to take the work started by Page Brooks (here, here, and here) and incorporate the Modal Popup functionality.

I ended up with a PopupColorPicker control. Here’s a picture of it in all of its popped-up glory:

Popup Color Picker Control

This control uses the Hue/Saturation/Value color space to translate colors to and from RGB values (through the HSVColor structure that is similar to the Color structure). The control also includes selecting a value for the opacity.

The control initially displays a color display box/button, which opens the Popup panel to select the color, and a text box, which a user can enter in an ARGB value directly. When the user clicks the color display button, the Popup panel is displayed (as shown above). On the left the user selects the hue, in the middle the saturation and value, and on the right the opacity.

The source code can be downloaded from CodePlex.

Hope this is useful!

2 Comments »

  1. Hey, quite nice and powerfull colorpicker – good example… If you are looking for a colorpicker like the ones in Microsoft Office – this is also a valid option: http://endofstream.com/creating-custom-colorpicker-in-silverlight/

    Comment by Peter — September 10, 2010 @ 1:20 am

  2. Thanks for the post, exactly what I was looking for

    Comment by Alex Ilyin — December 3, 2010 @ 1:00 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: