【发布时间】:2013-09-19 01:03:26
【问题描述】:
我有一些组合框是这样设置的:
<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>
ComboBox 正确填充了 ComboBoxItems,但单击文本 (Content) 不会选择该项目。我必须单击其他地方,那里没有文本来实际更改所选项目。
如果我把它改成这样:
<ComboBox Name="CB_OS" Grid.Row="5" SelectedIndex="0" Margin="2" SelectionChanged="OSSelectionChanged">
<ComboBoxItem Content="OOOOOOOOO"/>
<ComboBoxItem Content="OOOOOOOOO"/>
<ComboBoxItem Content="OOOOOOOOO"/>
</ComboBox>
效果很好。
OS_Selection 仅包含以下成员:
private string name;
private bool isChecked;
private bool isSelected;
所以我的问题是:如何使整行(项目)可点击?
【问题讨论】:
标签: wpf data-binding combobox