I see what looks like a bug in infragistics xamdatagrid.
What I am doing is
a) Changing grid.DataSource to a new ITypedList
b) calling dispose on my old list
c) Adding a new field to the current fieldlayout (which is still valid for the new datasource)
The grid is calling back at step c on my original datasource asking for ItemProperties. My collection is already disposed, so this throws. Once you change DataSource, why would the grid care about the old datasource -- especially when my fieldlayout was created manually -- and before I set the datasource at all.
Here is the call stack:
InfragisticsWPF3.v10.3.dll!Infragistics.Windows.Internal.TypedListPropertyDescriptorProvider.GetProperties() + 0x2d bytes InfragisticsWPF3.DataPresenter.v10.3.dll!Infragistics.Windows.DataPresenter.FieldLayout.LayoutPropertyDescriptorProvider.VerifyFieldDescriptors() + 0x15b bytes InfragisticsWPF3.DataPresenter.v10.3.dll!Infragistics.Windows.DataPresenter.FieldLayout.VerifyAllPropertyDescriptorProviders() + 0x90 bytes InfragisticsWPF3.DataPresenter.v10.3.dll!Infragistics.Windows.DataPresenter.FieldCollection.InsertItem(int index, Infragistics.Windows.DataPresenter.Field item) + 0x19f bytes
GetProperties is calling into the wrong object.
This is wrong on a few levels -- because the propertydescriptors themselves may have changed while the field definitions are still valid.
It looks like when the internal DataSource property changes, it only changes the propertydescriptor providers if the fieldlayout isn't already initialized. So it seems to be holding a weakref on the old datasource for this validation.
You probably want to reinitialize _propertyDescriptorProviders when the DataSource changes. At least, this is what I can gleam from reflector.
Thanks for any help.
Thanks for reporting this.
I have submitted a bug for it and will ask developer support to link it to this thread so you will get notified when it is fixed.
As a workaround in the meantime you could do the following:
That works, but requiring a reload of the fieldlayout is a perfomrance bug as switching datasources quickly is an important scenario for our users.
The only other workaround I can think of with the current bits is to not throw the exception inside your implemenation of ITypedList.GetItemProperties(null) and instead try just retuning an empty PropertyDescriptorCollection.
I'm not sure it won't since I haven't tried it but it might be worth a try.
If returning an empty propertydescriptorcollection wont blow up the field validation, we'll definitely go that route. Thanks