【发布时间】:2010-07-30 21:47:24
【问题描述】:
这是我的代码:
xaml 方面: 我使用数据模板与项目“dataType1”绑定
<DataTemplate DataType="{x:Type dataType1}">
<WrapPanel>
<CheckBox IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" Command="{Binding Path=CheckedCommand} />
<TextBlock Text="{Binding Path=ItemName, Mode=OneWay}" />
</WrapPanel>
</DataTemplate>
然后我创建一个包含“dataType1”类型的项目的组合框
<ComboBox Name="comboBoxItems" ItemsSource="{Binding Path=DataItems, Mode=TwoWay}">
这里是dataType1的定义:
class dataType1{public string ItemName{get; set;} public bool IsChecked {get; set;}}
场景是我准备了一个 dataType1 列表并将其绑定到 ComboBox,ItemName 完美显示,而 CheckBox IsChecked 值始终未选中,无论 dataType1 中“IsChecked”的值如何。
在 wpf 的 CheckBox 中绑定 IsChecked 属性是否需要特殊处理?
梁彼得
【问题讨论】:
标签: wpf data-binding checkbox