Hello,I ran into this issue and I wanted to signal it if someone else stumble on it as well. XAML XAML <ig:XamGrid ItemsSource="{Binding Path=GridTreatmentDetails}" AutoGenerateColumns="False" > <ig:XamGrid.Columns> <ig:DateColumn Key="DetailDateAsDateTime" HeaderText="DATA"/> <ig:TextColumn Key="Description" HeaderText="DESCRIZIONE"/> <ig:TextColumn Key="LastAndFirstName" HeaderText="PAZIENTE"/> <ig:TextColumn Key="TranslatedState" HeaderText="STATO"/> </ig:XamGrid.Columns> <ig:XamGrid ItemsSource="{Binding Path=GridTreatmentDetails}" AutoGenerateColumns="False" > <ig:XamGrid.Columns> <ig:DateColumn Key="DetailDateAsDateTime" HeaderText="DATA"/> <ig:TextColumn Key="Description" HeaderText="DESCRIZIONE"/> <ig:TextColumn Key="LastAndFirstName" HeaderText="PAZIENTE"/> <ig:TextColumn Key="TranslatedState" HeaderText="STATO"/> </ig:XamGrid.Columns> ViewModel GridTreatmentDetails = workHorseQuotes.SelectMany(td => td.MergedTreatmentDetails);GridTreatmentDetails is an IEnumerable<T> where T is my custom class.I receive a runtime error that says: The following key(s) do not correspond with the DataSource: "DetailDateAsDateTime".If you'd like to add additional columns, please use the UnboundColumn type. The following key(s) do not correspond with the DataSource: "DetailDateAsDateTime".If you'd like to add additional columns, please use the UnboundColumn type. It looks like my class does not have a DateTime property named DetailDateAsDateTime, but in fact I do have this property.To solve the issue you need to modify: GridTreatmentDetails = workHorseQuotes.SelectMany(td => td.MergedTreatmentDetails);as following: It looks like my class does not have a DateTime property named DetailDateAsDateTime, but in fact I do have this property.To solve the issue you need to modify: GridTreatmentDetails = workHorseQuotes.SelectMany(td => td.MergedTreatmentDetails);as following:GridTreatmentDetails = workHorseQuotes.SelectMany(td => td.MergedTreatmentDetails).ToList(); Now, while I can understand the reason (now), it would help immensly to receive a different error message.Best regards Roberto
Hello,I ran into this issue and I wanted to signal it if someone else stumble on it as well.
XAML
<ig:XamGrid ItemsSource="{Binding Path=GridTreatmentDetails}" AutoGenerateColumns="False" > <ig:XamGrid.Columns> <ig:DateColumn Key="DetailDateAsDateTime" HeaderText="DATA"/> <ig:TextColumn Key="Description" HeaderText="DESCRIZIONE"/> <ig:TextColumn Key="LastAndFirstName" HeaderText="PAZIENTE"/> <ig:TextColumn Key="TranslatedState" HeaderText="STATO"/> </ig:XamGrid.Columns>
<ig:XamGrid.Columns> <ig:DateColumn Key="DetailDateAsDateTime" HeaderText="DATA"/> <ig:TextColumn Key="Description" HeaderText="DESCRIZIONE"/> <ig:TextColumn Key="LastAndFirstName" HeaderText="PAZIENTE"/> <ig:TextColumn Key="TranslatedState" HeaderText="STATO"/>
The following key(s) do not correspond with the DataSource: "DetailDateAsDateTime".If you'd like to add additional columns, please use the UnboundColumn type.
It looks like my class does not have a DateTime property named DetailDateAsDateTime, but in fact I do have this property.To solve the issue you need to modify: GridTreatmentDetails = workHorseQuotes.SelectMany(td => td.MergedTreatmentDetails);as following:
Now, while I can understand the reason (now), it would help immensly to receive a different error message.Best regards
Roberto
Hello Rob,I knew that before, and in fact I recognized the error myself and fixed it.
This is not the point. The problem is that the message shown in the error is misleading. Since it could be a relatively common mistake to bind to a LINQ query, it would certainly help to show a message like:You're trying to bind to a LINQ query... you've spent too much time without taking a break, take it now.
Hi Roberto,
The reason this error occurs and actually makes sense from the Grid's standpoint is because of the difference between a LINQ query and the execution of the query. The line GridTreatmentDetails = workHorseQuotes.SelectMany(td => td.MergedTreatmentDetails) is only creating the query statement. It does not get executed until you iterate over the query variable which is now GridTreatmentDetails. Once the query is executed you have access to the actual data.
So from the Grid's standpoint, you're binding to a query variable which doesn't know anything about the data yet since it hasn't been executed. This means the column keys that were set don't match and you get the error. Changing that line to add the ToList() is what executes the query for you because ToList is iterating over the query and adding the selected data into a list. At the end of it all you have a list of actual data that your columns can see.
Thank you for pointing this out. This is very good to know. I agree that the error message is misleading and I'm going to look into it.