【问题标题】:How to edit boolean in a DataGridCheckBoxColumn in Silverlight 3如何在 Silverlight 3 的 DataGridCheckBoxColumn 中编辑布尔值
【发布时间】:2011-02-05 04:42:31
【问题描述】:

我有一个datagrid,还有一些TextColumn 和一个DataGridCheckBoxColumn。我将它与包含布尔值的itemsource 绑定,我可以看到我的checkboxes 或通过布尔值检查与否,此时一切正常。

但即使我指定IsReadOnly = False,复选框单元格也处于只读状态。我找不到正确且干净的方式来启用编辑。

我不需要数据验证,只需要能够编辑和选中这些复选框。

【问题讨论】:

  • ItemsSource 中的项目有可写的Available 属性? xaml 和代码的简短示例会有所帮助。

标签: .net silverlight datagrid checkbox silverlight-3.0


【解决方案1】:

DataGridCheckBoxColumn 上的绑定模式是否设置为 TwoWay ?

此代码对我有用。

<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.

【讨论】:

  • Mode有什么区别?
  • @Polo - 我已经修改了我的答案以包括绑定模式。
猜你喜欢
  • 2013-08-09
  • 2020-10-09
  • 2023-03-17
  • 1970-01-01
  • 2018-06-05
  • 2022-06-26
  • 2010-12-23
  • 1970-01-01
  • 2017-04-06
相关资源
最近更新 更多