databinding error when binding to read-only property

Oct 7, 2008 at 4:22 PM
i use the following xaml to bind a column to a data object with a read-only property (only getter available):
<toolkit:DataGridTextColumn Header="Name" DataFieldBinding="{Binding Path=FullName, Mode=OneWay}" Width="150*" />

When i run this code, I get an exception that "TwoWay or OneWayToSource binding cannot work on the read only property "FullName"."
But I explicitely set a OneWay binding!? What am I doing wrong?
Any help greatly appreciated.

Oct 7, 2008 at 4:55 PM
Even if you explicitly set the Mode to OneWay in the declaration, it is coerced to be TwoWay.  There is a related bug that does not let you set bindings on read-only properties.  When the final release comes out, what you can do is set IsReadOnly to true on the column and the OneWay will work correctly.  A workaround for the time being is to create a DataGridTemplateColumn and set the bindings there.
Oct 8, 2008 at 7:29 AM
Thank you very much for your quick help!

Dec 8, 2008 at 4:27 PM
Is this fixed in V1?
Dec 8, 2008 at 10:59 PM
If you set IsReadOnly = true on the DataGridColumn it should work with a read-only property.
Jan 22, 2009 at 3:10 AM
Edited Jan 22, 2009 at 3:11 AM
I just ran into this issue in V1 so no it is not. The workaround provided by vinsibal works fine though.

Apr 29, 2010 at 9:48 PM
I ran into the same issue, setting IsReadOnly="True" worked great, as vinsibal suggests. Thanks!