OneWay绑定抛出"TwoWay绑定在只读属性上无效"

Bin*_*ier 3 data-binding wpf xaml

这种约束力

<tk:DataGridTextColumn Binding="{Binding Path=Id, Mode=OneWay}" 
Header="Sale No." Width="1*" />
Run Code Online (Sandbox Code Playgroud)

给出了这个错误

TwoWay或OneWayToSource绑定不能对类型的只读属性"Id"起作用...

"Id"属性确实是只读的,我想虽然这样Mode=OneWay就足够了.

我很累,而且我知道我错过了一些明显的东西所以我现在道歉要问一个非常愚蠢的问题.

谢谢
BW

Jos*_*osh 5

如果我没记错的话,我认为DataGridTextColumn会在生成编辑元素时踩踏Binding.Mode,因为如果DataGrid是可编辑的,列本身仍默认为读/写.尝试在DataGridTextColumn上设置IsReadOnly ="true".