代码之家  ›  专栏  ›  技术社区  ›  Brandon Montgomery

Silverlight数据网格集单元格仅以编程方式读取

  •  1
  • Brandon Montgomery  · 技术社区  · 14 年前

    我正在将数据网格绑定到任务对象的集合。特定列需要一些与编辑相关的特殊规则:

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

    我要做的是基于实际任务对象的属性为每个任务的完成百分比单元格设置isReadOnly属性。我试过这个:

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

    但显然不能绑定到数据网格列上的isReadOnly属性。做我想做的事最好的方法是什么?

    2 回复  |  直到 14 年前
        1
  •  1
  •   Neil Knight    14 年前

    我不认为你能直接和这个联系在一起。我已经找到了这个扩展的silverlight数据网格,它可以完成这个任务。

    Extended DataGrid

        2
  •  0
  •   DaveB    14 年前

    看起来像是 DataGridColumn.IsReadOnly Property 是一个 DependencyProperty 所以应该是可以装订的。将xaml更改为 IsReadOnly="{Binding IsNotLocalID}" (注意添加的引号)看看会发生什么。在visual studio输出窗口中是否有任何绑定失败?