I have several list boxes, and a single a collection. The collection consists of structs, and each struct contains several color brushes. I set the source property of the list boxes to the collection and then in the template for each of the list boxes, bind the background property of a canvas to one of the brushes. Each list box displays different but complimentary colors in the same order.
My difficulty comes when I try and get the the selected color from a list box. The selected item is a struct and I cannot find a way of telling which color is being displayed. Here's some code to illustrate the problem:
<ListBox.ItemTemplate>
<DataTemplate>
<Canvas Background="{Binding colorBrush1}" Width="16" Height="16"/>
</DataTemplate>
</ListBox.ItemTemplate>
How do I get to the template Canvas Background property for the currently selected item such that I can get the color of the currently selected item ?