This element is one more control from the ColorPicker constituent controls bug in addition to ones published in my recent posts.
ColorSaturationBox element is designed as the tool to select a Color from the mix of some Color with the White and Black colors. It extends the
FrameworkElement. The idea of this element is borrowed from the Uncommon Dialogs: Font Chooser & Color Picker Dialogs article.
The color surface to select color from is the superposition of some color gradients. Roughly it consists of
- Vertical BaseColor-Black gradient.
- Vertical White-Black gradient with Horizontal Opacity mask gradient.
BaseColor is the variable reference color you can get or set with the
BaseColor Dependency Property.
That is the sample.
ColorSaturationBox element is at the top-left window corner. At right of it is the
RainbowSlider (see here) used to select the value of BaseColor. The SelectedColor sample is at the right-top corner. Below it the SelectedColor components are displayed in numbers.
You select the color with the color selector (small white circle with black border). You can drag it with the mouse or just click anywhere on the
ColorSaturationBox element surface. A propos, you can provide you own color selector drawing with the
ColorSaturationBox.Selector Dependency Property.
Dependency Property used to get the value of the Color selected. User can change the
SelectedColor property from its code using the
SelectorPosition property. The
SelectorPosition property gets or sets the selector position normalized to [0,1 0,1] rectangle. When the
SelectedColor changes the
ColorSaturationBox raises the
You can download the code and the samples here:
The archive contains my WPFGears library with samples, tests, etc. It’s the Visual Studio 2008 SP1 solution targeted to .NET Framework 3.5.
You’ll find ColorSaturationSample project there.
ColorSaturationBox element code is in the WPFGears library project ColorPickerControls folder.
Oleg V. Polikarpotchkin