[英]WPF DataGrid CheckBoxColumn binding mode = TwoWay error
Here is my code 这是我的代码
<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>
I have an exception Binding type TwoWay OneWayToSource or can not work with read-only property "chk" type "System.Data.DataRowView". 我有一个异常绑定类型TwoWay OneWayToSource或不能与只读属性“ chk”一起使用,类型为“ System.Data.DataRowView”。
When I do mode = OneWay, all good.But i need to change the target object and source object 当我执行mode = OneWay时,一切都很好。但是我需要更改目标对象和源对象
Your property binded to ComboBox "chk" does not have "set" implemented and so as it has only get it is considered as readonly . 绑定到ComboBox“ chk”的属性没有实现“ set”,因此只有它才被视为readonly。 Implement set and call INotifyPropertyChanged interface to notify change in the property. 实现set并调用INotifyPropertyChanged接口以通知属性更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.