Hi,
This is a newbie question. I Am doing some performance tests on the grid.
I Have a XAMDataGrid bound to an observable collection of my custom class objects.
In my data class I have some static properties and I am also dynamically adding some properties using the ICustomTypeDescriptor interface.
The problem I Have is that the grid is only showing the static columns, and not the dynamically added ones. I tried handing the FieldInitialisd events and adding the custom columns manually, but I Am not able to get them to bind properly.
So my question is how do I get the grid to bind to dynamic columns added via the CustomTypeDescriptors?
Appreciate any help,
thanks
BIjesh
I Was hoping for any update on this question. Or if the question was unclear or if any more information was needed, etc?
thanks and regards
Bijesh
Hello BIjesh,
Could you please give more information on why you are using CustomDescriptiors and what you are trying to achieve?
Thanks,
Alex
Hi Alex.
Thank you for the response. Basicaly we are evaluating the Infragistic grid (among other WPF grids) for use in a large project, both for functioanlity and performance.
In our case some of the screens have more that 100 columns. Typically not all will be displayed but that is up to the user. So we are writing some test code where we can set the no: of columns in the data to 10, 50, 100 etc and test the performance.
Obviously we don't want to type this in manually so would rather have them created dynamically using Custom Descriptors.
This is what we are trying to do. But I am unable to see the extra columns added this way,
Bijesh,
Thanks for clearing that out. I am not really sure why these changes are not reflected by the XamDataGrid and I have brought that up to the development team. Until I get an update from them, you can use UnboundFields and set their BindingPath to an already existing property of the underlying class (which I am assuming you are using, rather than DataTable, in which case is pretty straightforward).
like:
<igDP:Field Name="Column1" />
<igDP:UnboundField Name="Column1" BindingPath="Column1"/>
<igDP:Field Name="Column2" />
<igDP:Field Name="Column3" />
<igDP:Field Name="Column4" />
Hi Alex,
Thanks. I will try this out. But please do get back to me when you get an update from the dev team, as I am not sure whether this way will really test a scenario where the data itself has around 100 columns.
Also I've noticed that if I set the columns in XAML I can't then change the collection object that it is bound to at runtime as it throws an exception:"Can't set the DataSource on a DataPresenter that has items added explicitly through the DataItems collection." Is this by design?
Anyway I will try to set the fieldlayout programattically, but do let me know if it is possible to use custom type descriptors..
The development updated me. We do not support ICustomTypeDescriptor with the XamDataGrid, as the properties are retrieved based on the type and not on the instance of the object. One way for achieving this effect is to implement ITypedList (so that the XamDataGrid will make a query for the properties) and IBindingList ( so that the ListChanged event will fire as notification when adding/removing properties). This is basically the mechanism how datatable works, so you can try binding the XamDataGrid to a DataTable and add/remove columns if that is possible in your scenario.
Alex,
Any changes in ICustomTypeDescriptor support for xamDatagrid since this answer was posted?
Any plans to support?
Regards,
Sergei.