【问题标题】:How to bind to DataGridCheckBoxColumn in MVVM如何绑定到 MVVM 中的 DataGridCheckBoxColumn
【发布时间】:2011-07-28 11:16:37
【问题描述】:

我对这个 sn-p 有看法:

<DataGrid AlternatingRowBackground="#FFF2F5F1"
          AutoGenerateColumns="False"
          Grid.Row="0"
          GridLinesVisibility="None"
          IsReadOnly="False"
          IsSynchronizedWithCurrentItem="True"
          ItemsSource="{Binding Path=ClassSessionAttendenceAll}"
          SelectedItem="{Binding Path=SelectedAttendence, Mode=TwoWay}"
          Margin="5,5,5,5"
          RowHeight="20"
          SelectionMode="Single"
          IsEnabled="{Binding AttendenceGridEnabled}">

          <DataGrid.Columns>
              <DataGridTextColumn Binding="{Binding Path=ClientName}"                                                             
                                  Header ="Client's name" Width="2*"  />
              <DataGridCheckBoxColumn Binding="{Binding Attended, Mode=TwoWay, UpdateSourceTrigger =PropertyChanged}"
                                      Header="Is Present?"   
                                      Width="*">

              </DataGridCheckBoxColumn>
          </DataGrid.Columns>
</DataGrid>

我无法对 DataGridCheckBoxColumn 复选框的更改做出反应。 整个数据网格绑定到 List,DataGridTextColumn 绑定到属性 Attendance.ClientName,DataGridCheckBoxColumn 绑定到另一个属性 Attendance.Attended

那么,如何访问 ModelView 中更改的 CheckBox? 我可以进入 Selected 没问题.. 但是有“但是” - 检查事件发生在 select 事件之后,我没有得到该复选框的选中状态。我可能错过了一步.. 但需要帮助才能做到.. :).. 谢谢!

【问题讨论】:

    标签: mvvm


    【解决方案1】:

    【讨论】:

    • 是 Silverlight DataGrid 复选框事件吗? - 真的有帮助,我让它工作..从后面的代码.. :).. 但仍然使它工作..,丹的建议......对于我需要的东西来说太过分了,但无论如何,感谢 Derek 的链接!
    猜你喜欢
    • 2018-06-20
    • 2012-05-25
    • 2011-02-02
    • 2013-06-15
    • 1970-01-01
    • 2011-05-08
    • 2021-07-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多