Basic idea is: populate your combo box with all brushes you need. For list item content, use members of
System.Windows.Media.Brushes
, see
http://msdn.microsoft.com/en-us/library/system.windows.controls.combobox.aspx[
^]. In the handler of the event of
ComboBox.SelectionChanged
, type-cast the content of the combo box element to
SolidColorBrush
and assign it to the property
Fill
of the
Ellipse
.
For a combo box item, you can use as complex content as you want; it is only important that you have object of the type
SolidColorBrush
or
Brush
at some level of nesting. In this way, you can show color and, for example, its name in the combo box list item.
Here is a very simple example:
<ComboBox>
<ComboBoxItem>
<TextBlock Background="Red">Red</TextBlock>
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Background="Yellow">Yellow</TextBlock>
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Background="AliceBlue">Alice Blue</TextBlock>
</ComboBoxItem>
</ComboBox>
It's not perfect, just gives you the idea what can you have for a control (combo box) used for color selection.
All trick is in the design of a
ComboBoxItem
content and using it. So, read this:
http://msdn.microsoft.com/en-us/library/bb613548.aspx[
^].
Another different level of WPF "custom drawing" is
styling and
templating. Read
http://msdn.microsoft.com/en-us/library/ms745683.aspx[
^].
—SA