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:
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!
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
Thanks for the post, exactly what I was looking for
Comment by Alex Ilyin — December 3, 2010 @ 1:00 am