【发布时间】:2016-05-12 09:12:42
【问题描述】:
我想在DataGrid 的列中同时拥有一个CheckBox 和一个TextBlock,如下所示:
<DataGrid CanUserAddRows="False" CanUserDeleteRows="False" >
<DataGrid.Columns>
<DataGridTemplateColumn Header="one">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock x:Name="textBlock1"></TextBlock>
<CheckBox x:Name="checkBox1"></CheckBox>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
我想将数据库中的数据绑定到该列:
我在数据库字段中的数据是这样的:"0-Hello" 或"1-Bye"
如果字段为"0-hello",则应取消选中checkBox1,并且textBlock1 应等于"hello"。
如果字段为"1-bye",则应检查checkBox1,并且textBlock1 应等于"hello"。
我该怎么做?
【问题讨论】:
标签: wpf binding datagrid datagridcolumn