I'm trying to create a ListBox in which the text of the items is bound to the regionName property of the objects in its ItemSource. This is displaying as it should be, but clicking on the text created by the binding does not change the ListBoxItem's state to "selected" (although clicking on the space after the text selects the item.) The ListBox behaves as expected when I use the DisplayMemberBinding
property or when I set Content
to random static text in the DataTemplate (clicking on the text selects the ListBoxItem). However, I would like to use a converter to set the text color on the individual items (different items will be different colors), so it seems that I have to use a DataTemplate, which cannot be used in conjunction with the DisplayMemberBinding
property. Has anyone else encountered this issue?
XAML for the list box:
<ListBox x:Name="x_UpdateAreaListBox" Margin="0,0,0,10" SelectionChanged="x_UpdateAreaListBox_SelectionChanged" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem Content="{Binding Path=regionName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>