Hi all,
I am using a RadGridView to display a list of DataRowBase objects which implements the ICustomTypeDescriptor. When the grid starts to populate its rows I observed some "first chance" ArgumentExceptions printed out in the output window of the IDE. ("An exception (first chance) of the type "System.ArgumentException" occurred in System.ComponentModel.DataAnnotations.dll" - translated from German).
As the grid showed all my data correctly, I could probably ignore the messages - but it was very slow in doing so. So I used a hard-coded class with the same data and the same grid and this was significantly faster (and didn't throw any exceptions). (I need to use a generic approach as the application allows the user to display data of csv files and I want to utilize all features of the grid view, like filtering, sorting, grouping etc.)
I took my while to find out how to track this exception message down to its root:
The original exception message is: "The type "DataRowBase" does not contain a public property "RefDate"." (translated from German, may not be accurate)
And it seems to be thrown by some code in "GridViewVirtualizingPanel.cs".
I can't see whether this exception is thrown by the above class or somewhere deeper in the .net framework (as the message in the output window suggests, see above). But it is interesting to see that the exception is thrown only once per row, not per row and column (as all my columns are generic).
This leads to the assumption that the interface ICustomTypeDescriptor is not used properly. I found a very helpful article on how this interface is used by System.ComponentModel.TypeDescriptor in an older issue of the MSDN Magazine: MSDN Magazine: ICustomTypeDescriptor, Part 1: "... Before going straight to the metadata to get property information, TypeDescriptor first checks to see if the type being examined implements the System.ComponentModel.ICustomTypeDescriptor interface. If it does, (...), rather than using the metadata to get property information, TypeDescriptor will simply ask the object (through its ICustomTypeDescriptor.GetProperties method) which properties it supports."
I added some Debug.WriteLine's to my ICustomTypeDescriptor.GetProperties() implementation and this revealed that
a) the above exception is thrown after a first call to GetProperties() of each(!) DataRowBase instance in my list, and
b) GetProperties() is called for every displayed column of the same instance (w/o exception) [why that? An initial call should be sufficient]
My question is here: Is this a problem of the RadGridView? Or does the problem lie deeper within the framework?
Any help/suggestion is highly appreciated!
Thanks,
Thorsten
PS
I am using RadControls for WPF, Q2 2013 and WPF 4.5
I am using a RadGridView to display a list of DataRowBase objects which implements the ICustomTypeDescriptor. When the grid starts to populate its rows I observed some "first chance" ArgumentExceptions printed out in the output window of the IDE. ("An exception (first chance) of the type "System.ArgumentException" occurred in System.ComponentModel.DataAnnotations.dll" - translated from German).
As the grid showed all my data correctly, I could probably ignore the messages - but it was very slow in doing so. So I used a hard-coded class with the same data and the same grid and this was significantly faster (and didn't throw any exceptions). (I need to use a generic approach as the application allows the user to display data of csv files and I want to utilize all features of the grid view, like filtering, sorting, grouping etc.)
I took my while to find out how to track this exception message down to its root:
The original exception message is: "The type "DataRowBase" does not contain a public property "RefDate"." (translated from German, may not be accurate)
And it seems to be thrown by some code in "GridViewVirtualizingPanel.cs".
I can't see whether this exception is thrown by the above class or somewhere deeper in the .net framework (as the message in the output window suggests, see above). But it is interesting to see that the exception is thrown only once per row, not per row and column (as all my columns are generic).
This leads to the assumption that the interface ICustomTypeDescriptor is not used properly. I found a very helpful article on how this interface is used by System.ComponentModel.TypeDescriptor in an older issue of the MSDN Magazine: MSDN Magazine: ICustomTypeDescriptor, Part 1: "... Before going straight to the metadata to get property information, TypeDescriptor first checks to see if the type being examined implements the System.ComponentModel.ICustomTypeDescriptor interface. If it does, (...), rather than using the metadata to get property information, TypeDescriptor will simply ask the object (through its ICustomTypeDescriptor.GetProperties method) which properties it supports."
I added some Debug.WriteLine's to my ICustomTypeDescriptor.GetProperties() implementation and this revealed that
a) the above exception is thrown after a first call to GetProperties() of each(!) DataRowBase instance in my list, and
b) GetProperties() is called for every displayed column of the same instance (w/o exception) [why that? An initial call should be sufficient]
My question is here: Is this a problem of the RadGridView? Or does the problem lie deeper within the framework?
Any help/suggestion is highly appreciated!
Thanks,
Thorsten
PS
I am using RadControls for WPF, Q2 2013 and WPF 4.5