Silverlight DataGrid set cell IsReadOnly programatically

Posted by Brandon Montgomery on Stack Overflow See other posts from Stack Overflow or by Brandon Montgomery
Published on 2010-03-29T21:06:07Z Indexed on 2010/04/01 5:23 UTC
Read the original article Hit count: 752

Filed under:
|
|

I am binding a data grid to a collection of Task objects. A particular column needs some special rules pertaining to editing:

<!--Percent Complete-->
<data:DataGridTextColumn Header="%" 
                         ElementStyle="{StaticResource RightAlignStyle}" 
                         Binding="{Binding PercentComplete, Mode=TwoWay, Converter={StaticResource PercentConverter}}" />

What I want to do is set the IsReadOnly property only for each task's percent complete cell based on a property on the actual Task object. I've tried this:

<!--Percent Complete-->
<data:DataGridTextColumn Header="%" 
                         ElementStyle="{StaticResource RightAlignStyle}" 
                         Binding="{Binding PercentComplete, Mode=TwoWay, Converter={StaticResource PercentConverter}}"
                         IsReadOnly={Binding IsNotLocalID} />

but apparently you can't bind to the IsReadOnly property on a data grid column. What is the best way do to do what I am trying to do?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about datagrid