so i'm having the issue of getting a null reference when checking the checkbox column on my data grid, though this only occurs when the checkboxes are outside of view at startup of the program. E.g. checks until the first 20 visible rows are fine, but not there after.
Here's my iteration code:
My item source is a List of Type which i need to instantiate if the row is checked. 'permissions' is a PermissionSet which I need to populate.
foreach (Type t in dataGridPerms.ItemsSource)
{
try
{
bool? check = ((CheckBox)AllowColumn.GetCellContent(t)).IsChecked; //offending line
if (check == true)
{
Object o = Activator.CreateInstance(t, PermissionState.Unrestricted);
permissions.AddPermission((IPermission)o);
}
}
catch(Exception e)
{
continue;
}
}
I have searched online but found no solid help, though I have read bits on data binding which may be of use but I don't really have an idea on where to start if that is the solution as i am new to WPF.
Many thanks for any help :)
Edit:
The duplicate question/answer provided is a very stripped down version of my issue. My issues relates closely to WPF and it's constructs.