2010-04-07 35 views
2

我有一个datagrid,其中有一些TextColumn和一个DataGridCheckBoxColumn。我将它与包含布尔值的itemsource进行绑定,我可以看到我的checkboxes或者通过布尔值检查或不检查在这一点上是否正确。如何在Silverlight 3的DataGridCheckBoxColumn中编辑布尔值

但是复选框单元格在ReadOnly中,即使我分配了IsReadOnly = False。我无法找到正确且干净的方式来启用编辑。

我不需要数据验证,但有理由能够编辑和检查这些复选框。

enter image description here

+0

的项目中的ItemsSource也可写'Available'财产? xaml和代码的简短示例会有所帮助。 – AnthonyWJones 2010-04-07 10:52:31

回答

2

是绑定模式为双向的DataGridCheckBoxColumn?

此代码适用于我。

<data:DataGrid Grid.Row="1" Width="600" MaxHeight="200" 
    GridLinesVisibility="Horizontal" 
    AutoGenerateColumns="False" VerticalScrollBarVisibility="Auto" 
    HorizontalScrollBarVisibility="Auto" 
    ItemsSource="{Binding Path=ProductPull.Items, Mode=OneWay}"> 
     <data:DataGrid.Columns> 
      <data:DataGridCheckBoxColumn Header="Select" 
       Binding="{Binding Path=IsSelected, Mode=TwoWay}" /> 

编辑

Silverlight Data Binding这里是结合模式:

Direction of the Data Flow 
    -------------------------------------------------------------------------------- 

    Each binding has a Mode property, which determines 
how and when the data flows. Silverlight enables three types of bindings: 

    OneTime bindings update the target with the 
source data when the binding is created. 

    OneWay bindings update the target with the 
source data when the binding is created and anytime the data changes. 
This is the default mode. 

    TwoWay bindings update both the target and the 
source when either changes. Alternately, you can disable 
automatic source updates and update the source only at times of your choosing. 

    In order for automatic target updates to occur, 
the source object must implement the INotifyPropertyChanged interface, 
as described in the next section. 
+0

模式有什么区别? – Polo 2010-04-08 08:51:29

+1

@Polo - 我已经修改了我的答案,以包含绑定模式。 – DaveB 2010-04-08 15:22:24