Normal 0 false false false EN-US X-NONE X-NONE
Dear SL Forum
We have an ObservableCollection of customer classes of type System.Dynamic
.DynamicObject s that have some class properties as well as a GetPropertyValue method. In debug mode, at just prior to assigning my ObservableCollection to myxamWebGrid.ItemsSource I can validate my collection:
((MyDynamicObject)(myObservableCollectionOfMyDynamicObject [0])).GetPropertyValue("myPropertyName")
and get a valid result in my QuickWatch view.
However, upon assigning myxamWebGrid.ItemsSource = myObservableCollectionOfMyDynamicObject
I get:
The following key(s) do not correspond with the DataSource: "myPropertyName ". If you'd like to add additional columns, please use the UnboundColumn type.
The xamWebgrid’s columns are created at runtime, where each column is an Infragistics.Silverlight.Controls.TextColumn
The HeaderText and Key properties for each TextColumn is assign a value. The Key property is assigned a value that matches the appropriate value for the ((MyDynamicObject)(myObservableCollectionOfMyDynamicObject [0])).GetPropertyValue method parameter, e.g. ‘myPropertyName’ going with my example above.
I believe the issue is that my assumption that the TextColumn key value will be passed to the GetPropertyValue was incorrect, but confirmation would be nice.
What would be a better approach to achieve my goal binding an xamWebGrid to an ObservableCollection of custom DymamicObjects.
Thank you in advance.
Hi,
So the trick here is to expose a property on your "DynamicObject" that has a string indexer, that will retrieve the values you that you want, and then to set the keys of your columns to indexer properties
Check out the following forum thread for more details.
https://www.infragistics.com/community/forums/f/retired-products-and-controls/52457/add-templatecolumn-in-code-not-working/273260#273260
Hope this helps,
-SteveZ