Hello!
Can you show the sample how to add the row programmatically ( without ItemsSource property)?
Thank you.
Hi,
I actually thought about it a bit more, and i suppose you could use a XamlReader to generate a DataTemplate at runtime.
A colleague of mine actually pointed out an Article that shows this. It's using the MS DataGrid however, it translates the same way.
http://blogs.msdn.com/scmorris/archive/2008/04/14/defining-silverlight-datagrid-columns-at-runtime.aspx
Hope this helps.
-SteveZ
Thank you, Stephen!
Sorry, but I don` t get you.... Is it possible to create row and its column details as HeaderTemplate, ItemTemplate and EditTemplate in the rutime? If yes, just write some lines of code for me, please, because it is impossible without deep knowleges of xamWebGrid.
If it is impossible please write about it.
Sorry for my english...
Thank you for reply.
Check out our "Cell Editor Template" sample in the Silverilght LOB samples browser:
http://labs.infragistics.com/silverlight/lobsamples/2009.1/
This sample demonstrates how to put a ComboBox in a Template Column.
In Silverlight, you cannot create a DataTemplate in the code behind. You can create a TemplateColumn in the code behind, however, you'd have to have a predefined DataTemplate in the resources of your xaml, whether its your current page or app.xaml and then resolve the DataTemplate in the codebehind. And since you can't create a DataTemplate in the code behind, it means you'd have to know the names of your properties in advance.
Concerning anonymouse types: I am mistaked :), I consider dynamic types.
1. How to create programmatically column with dropdownlist and button. It is impossible?
2. How to create column with dropdownlist and how to bind it by photos, for example (I am about ValueList dictionary, as in Infragistics WinForms)?
Do you have any examples for this two points?
3.
>>Also, in this approach, TemplateColumns wouldn't be ideal, as you can't create DataTemplates in the >>code behind, which requires you to know what types of data you need and names of property in xaml.
But I can use reflection to read a type, property name and value?
Thank you for your help.
So, Anonymous types aren't supported in Silverlight. Which is why i recommend you look into a solution similar to the one in the article i sent.
Also, in this approach, TemplateColumns wouldn't be ideal, as you can't create DataTemplates in the code behind, which requires you to know what types of data you need and names of property in xaml.
So, your best approach would be to use Dynamic types similar to the article, and create columns on the fly, or the use of Autogenerated columns.
I' m not sure what you mean by SubTables, do you mean hiearchy? In which case, hierarchy is just another property in your datasource that is of type IEnumerable.
I know this must be a pain point, however i'd like to make it clear that this is a limitation in the Silverlight framework.