I have some ComboBoxes set up like this:
<ComboBox Name="CB_OS" Grid.Row="5" ItemsSource="{Binding OS_Sellection}" SelectedIndex="0" Margin="2" SelectionChanged="OSSelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<ComboBoxItem Content="{Binding Name}" IsSelected="{Binding IsSelected, Mode=TwoWay}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
The ComboBox fills with ComboBoxItems correctly, but clicking on the text (Content) does not select the Item. I must click elsewhere, where there is no text to actually change the selected item.
If I change it to this:
<ComboBox Name="CB_OS" Grid.Row="5" SelectedIndex="0" Margin="2" SelectionChanged="OSSelectionChanged">
<ComboBoxItem Content="OOOOOOOOO"/>
<ComboBoxItem Content="OOOOOOOOO"/>
<ComboBoxItem Content="OOOOOOOOO"/>
</ComboBox>
it works fine.
OS_Selection contains only the following members:
private string name;
private bool isChecked;
private bool isSelected;
So my question is: How can I make the entire row (item) clickable?
Sumit Kesarwani
21-Sep-2013Don't put a ComboBoxItem inside the ComboBox.ItemTemplate
Change this:
for this:
Also, WPF does not bind to private fields, only public properties.