DataGridCheckBoxColumn and IsReadOnly="True" fails

Mar 6, 2009 at 9:44 AM
Edited Mar 6, 2009 at 9:44 AM

Im using the datagrid and bind a bool-column. The grid itself is bind in OneWayMode and one bool property is implemented with a privat setter.

public bool IsDirty { get; private set; }

//xaml for bindig:
...ItemsSource="{Binding TransformedData, Mode=OneWay}" ...

//xaml for checkbox-column
<toolkit:DataGridCheckBoxColumn Binding="{Binding IsDirty}" IsReadOnly="True" Header="IsDirty"  />

//error message while binding:
"A TwoWay or OneWayToSource binding cannot work on the read-only property 'IsDirty' of type 'Namespace.TransformedData'."

What working is to use DataGridTextColumn instead of DataGridCheckBoxColumn. There is no need to describe thats only suboptimal. And to make the setter read/write too.
Is this a known bug? Did'nt find something about. Thanks for help.


Mar 6, 2009 at 10:56 AM
The problem is most likely that the binding to IsDirty is TwoWay (by default). Try setting Mode=OneWay on it and see if that helps.
Mar 6, 2009 at 11:40 AM
Thanks for your input, but as you can see this happened already:

//xaml for bindig:
...ItemsSource="{Binding TransformedData, Mode=OneWay}" ...

Mar 17, 2009 at 7:43 AM
Mar 25, 2009 at 10:09 AM
Thank you, thats it. It was unapparent to me, that Mode must be set in both declarations.