Hi,I have a property :
Protected WithEvents m_TabDetailDomainDataSource As DomainDataSource
Public ReadOnly Property TabDetailData() Get If m_TabDetailDomainDataSource IsNot Nothing Then Return m_TabDetailDomainDataSource.Data End If Return Nothing End Get End Property
And XamWebGrid:
<igGrid:XamWebGrid x:Name="grdDetail" ItemsSource="{Binding TabDetailData}"/>
When m_TabDetailDomainDataSource.Data have any row, grid binding ok.when i reload data and m_TabDetailDomainDataSource.Data have not any row, grid do not have layout. Why?
If i define any column in xam,
it throw exception
Thanks,
Hi Jaimir,
We do use the type from the collection.
Unless 'T' is of type 'object'.
Do you have a sample?
-SteveZ
Hi Steve,
Can you enumerate the Generic collection type? Becouse I use an IEnumerable<t> as return value and it doesn't work either.
Thank you
Jaimir G.
Hi,
In order for this to work, the grid would need to be bound to a Generic collection. If the collection is generic, then we can know about what data exists in your data source even if no data exists in it, and support such operations.
So, When grid have not any row, how can i AddnewItem on grid? because now there is not AddNewITem row.
So, when you assign an ItemSource, to the xamWebGrid, it first needs to evaluate what fields are possible. It does this a couple of ways. First, it tries to look at the first record. If it finds one, then it simply looks at all possible public properties. If there isn't any data, then it tries to see if the collection is generic, if so, then it takes a look at the generic type, and will try to determine the fields this way. Otherwise, it can't really do anything, as it knows nothing about the collection it's bound to. So, at that point, you're left with no columns, unless you're willing to wait until there is data. Assuming your collection implements INotifyCollectionChanged, the grid will know when data is added, and thus determine the fields at that point, and thus create the columns.
Now, when you change the ItemSource, to another, it immediately removes all columns that were AutoGenerated. If you're columns were not AutoGenerated, it's up to you the developer to clean them out.
When you specify columns, the columns MUST map to properties on your object, otherwise, you'll get the InvalidColumnKeyException you're seeing.
I hope this helps clarify what you're seeing.
-StteveZ