I have the following method to select all the checkboxes within my datagrid:
private void CheckboxSelectAll(int column)
{
for (int i = 0; i < twn; i++)
{
var row = (DataGridRow)dGrid.ItemContainerGenerator.ContainerFromIndex(i);
if (row == null) continue;
var chk = (System.Windows.Controls.CheckBox)dGrid.Columns[column].GetCellContent(row);
chk.IsChecked = true;
}
}
This only works so long as all the columns are in view. If, for example, the amount of checkboxes exceeds the height of the datagrid, it will not select those. I will have to scroll down, expose them to the view, and then reinvoke my method to finally select the remaining checkboxes.
What am I missing? These checkboxes are already databound.
If I change the height of the datagrid to expose more checkboxes, this allows me to select more. This is only a workaround and I would like to understand why and what about my code makes the checkboxes being exposed to the view important.
Aucun commentaire:
Enregistrer un commentaire