I have templated ComboBox that is basically acting as a simple colour palette. It is populated with a list of SolidColorBrush objects.
I also have some data that holds the hex value of the current colour and a converter that converts the hex into a SolidColorBrush.
What I am trying is to set the SelectedItem property of the ComboBox based on the colour from my DataSource. Since my combo is populated with objects of type SolidColourBrush, and my binding converter is returning a SolidColorBrush, I assumed it would be as simple as saying:
SelectedItem="{Binding Color, Converter={StaticResource StringToBrush}}"
However... it doesn't work :(
I've tested that the binding is working behind the scenes by using the exact same value for the Background property of the ComboBox.
So, clearly I can't just say SelectedItem = [something] where that [something] is basically an object equal to the item I want to be selected.
What is the right way to do this? Surely it's possible in a XAML-only styley using binding, and I don't have to do some nasty C# iterating through all items in the combobox trying to find a match (that seems awfully old-school)...?