Reputation: 6911
I have following code in an extended DataGrid to check or uncheck the CheckBoxColumn:
if (this.Columns[c] is DataGridCheckBoxColumn)
{
CheckBox cb = this.GetCellCtrl<CheckBox>(this.Columns[fromCol], topRow);
for (int r = fromRow + 1; r <= toRow; r++)
{
CheckBox tt = this.GetCellCtrl<CheckBox>(this.Columns[fromCol], this.GetRow(r));
if (tt != null)
tt.IsChecked = cb.IsChecked;
}
}
The problem is that the checkboxes are checked (or unchecked), but the underlying data are not updated. If I mouse-clicking the checkbox, it works. So, what's the difference between my code and mouse-clicking? How to solve my problem?
Upvotes: 0
Views: 503
Reputation: 70160
Setting a value locally will remove the binding that couples your CheckBox
to your data. Is there any reason why you are updating the state of your data via the UI? Why not use your same loop logic on the data?
If you really must do it this way, you should look into UI Automation:
http://msdn.microsoft.com/en-us/library/ms747327.aspx
Upvotes: 1