I have dug deep into the Record.cs source code file and found that the DataRecord class has a property named GetDataErrorInfo that returns the record's DataItem as IDataErrorInfo. However, this fails if the the Record's DataItem is a complex object of objects that support IDataErrorInfo. This complex object is the result of a LINQ to Objects query without a Select "clause" to preserve the ability to set the properties in the Objects used to build the query. Again, these objects in the linq query support IDataErrorInfo. The only way to expose the IDataErrorInfo.Error property is to loop the Cells finding UnboundFields and check if each Field's binding source supports IDataErrorInfo. Is this a bug or will the xamDataGrid never support complex binding? Is there another way to bind to multiple related sources so that I do not have to use UnboundFields and complex binding?
Thank You
Devin
Hello Devin,
I have been looking into your description and I cannot say for sure what is case here, since I am not exactly sure what is the data you are using. I was wondering if you could provide me with a class sample of the data object you described, or perhaps a test project, that I can look into further.
Thanks in advance. Looking forward to hearing from you.
How would I go uabout uploading a test project? I don't think I should write 300 lines of code in here.
Thanks
Found out how to upload.
Now to recreate what I am stating add a breakpoint to any one of the [Error] Properties that implements IDataErrorInfo.Error in my Data.vb file (it contains 3 data objects). Run the project with debug mode. Change any entry to blank (this is what the validation is looking for). The breakpoint will never be hit.
Now to get the breakpoint to hit, go to the xaml and change each one of the UnboundFields to a Field. Remove the bindingpath and the bindingmode. Change the names to remove the dot notation. Finally change the linq query from this:
Dim myOC = From o In ordersBL Join oi In orderItemsBL On o.id Equals oi.oid Join i In inventoryItemsBL On oi.iid Equals i.id Order By oi.oid
To this:
Dim myOC = From o In ordersBL Join oi In orderItemsBL On o.id Equals oi.oid Join i In inventoryItemsBL On oi.iid Equals i.id Order By oi.oid Select o.id, o.d, o.wc, oi.qty, i.name, i.descr
I have been looking into your attachment and I do see what is causing you trouble. In order for the XamDataGrid to keep track of the occurred errors in any data object class, the class must inherit from IDataErrorInfo and that way the XamDataGrid can use its errors instance. In your case you have set a query’s result, that returns a bunch of three different types, as DataSource thus depriving the XamDataGrid of data object that inherits from IDataErrorInfo interface. In order to get this working you can try creating a wrapper class that will incorporate your query’s results and in which you would have to create a mechanism that would listen for the properties and sub properties’ errors if they occur.
Hope this helps. Please let me know if I can provide you with any further clarification on the matter.
I have considered your response and appreciate the time that you have invested in my question. I will accept the answer of creating a wrapper class, but feel that there should be a better way to handle this situation. Do you have any other suggestions on how to join two or more sources together and display them in a grid? It's just hard for me to accept that this is not an issue for other developers. Is this something that would be solved with me switching to the Entity Framework or some other Object Relational Mapping technique? Again, thank you for all of your time.
Sorry that I didn't close this. I am content with the wrapper class idea.
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Hi Devin,
Thank you for the feedback, it is surely noted. I just wanted to point out that I haven’t encountered anyone with a similar issue and perhaps this is why there isn’t a suggested resolution. Regarding using the Entity Framework and Object Relational Mapping it would still result they give you and its particular IDataErrorInfo capabilities.
Please let me know if can be of any further assistance on the matter.