System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=IsExpanded; DataItem='DataRecordPresenter' (Name=''); target element is 'ExpansionIndicator' (Name='ExpansionIndicator'); target property is 'IsChecked' (type 'Nullable`1') TargetInvocationException:'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: key not found
at Infragistics.Windows.DataPresenter.FieldCollection.get_Item(String key)
at InitializeRecordProblem.Window1.xamDataGrid1_InitializeRecord(Object sender, InitializeRecordEventArgs e) in D:\development\Stuff\Examples\InitializeRecordProblem\InitializeRecordProblem\Window1.xaml.cs:line 34...
It's because InitializeRecord is called on every single record in the datagrid - the child records as well as the parent records - and the child records don't have a field called "Selected". This is what's throwng the error. So you'll have to check whether you're trying to initialise the parent record or the child record before setting that field.
If you want the entire field to be false on startup, you don't even need to set it in code behind because the default value for a boolean field is already false.
I knew it was something simple, cannot believe I missed that! Thanks for your help.
Now I need to figure out why I decided I needed to set that to false in the first place - I guess I thought it was a 3 state checkbox but you are right, it does get initialized to false.
Thanks again.