开发者

OneWay binding throws "TwoWay binding is invalid on Read only property"

开发者 https://www.devze.com 2022-12-30 09:17 出处:网络
This binding <tk:DataGridTextColumn Binding=\"{Binding Path=Id, Mode=OneWay}\" Header=\"Sale No.\" Width=\"1*\" />

This binding

<tk:DataGridTextColumn Binding="{Binding Path=Id, Mode=OneWay}" 
Header="Sale No." Width="1*" />

Gives this error

A TwoWay or OneWayToSource binding cannot work on the read-only property 'Id'开发者_JAVA技巧 of type . . .

The "Id" property is indeed readonly, I thought though that Mode=OneWay would be sufficient.

I'm tired and I know I'm missing something obvious so I'll apologies now for asking a really dumb question.

Thanks

BW


If I recall correctly, I think that the DataGridTextColumn stomps on your Binding.Mode when it generates the editing element because the column itself still defaults to being read/write if the DataGrid is editable. Try setting IsReadOnly="true" on the DataGridTextColumn.

0

精彩评论

暂无评论...
验证码 换一张
取 消