Silverlight 3 Dataform - how to add fieds at runtime

故事扮演 提交于 2019-12-23 04:30:35

问题


I am creating a DataForm from dynamic data (so I can't create the columns in the xaml), I currently create columns for my DataGrid (I have not worked out how I can create a button + event in a colomn yet)

foreach (var item in headings.Entities)
                    {
                        theDataGrid.Columns.Add(
                            new DataGridTextColumn
                            {
                                Header = item.Label,
                                Binding = new Binding(item.LocalName)
                            });
                    }

I cannot see any methods to add fields to a DataForm at runtime, however...


回答1:


You'd be better off not creating your datagrid columns in code, but using bindings instead. Just bind the datagrid to the headings.Entities collection.

The same thing with your DataForm, just bind your item to it and it should create all the proper fields for you.



来源:https://stackoverflow.com/questions/1736696/silverlight-3-dataform-how-to-add-fieds-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!