【发布时间】:2015-09-15 10:10:56
【问题描述】:
这是我的代码
<DataGrid.Columns>
<DataGridTemplateColumn Header="" Width="30" IsReadOnly="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path = chk, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGridTemplateColumn.CellStyle>
</DataGridTemplateColumn>
我有一个例外 绑定类型 TwoWay OneWayToSource 或不能使用只读属性“chk”类型“System.Data.DataRowView”。
当我做mode = OneWay时,一切都好。但是我需要改变目标对象和源对象
【问题讨论】: