Binary Worrier
Binary Worrier

Reputation: 51711

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

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' 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

Upvotes: 3

Views: 5872

Answers (1)

Josh
Josh

Reputation: 69262

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.

Upvotes: 5

Related Questions