本文介绍了Silverlight 3 Dataform-如何在运行时添加场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据动态数据创建DataForm(因此无法在xaml中创建列),当前正在为DataGrid创建列(我还没有弄清楚如何在列中创建按钮+事件.)

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)
                            });
                    }

我看不到任何在运行时将字段添加到DataForm的方法.

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

推荐答案

最好不要在代码中创建datagrid列,而应使用绑定.只需将datagrid绑定到headings.Entities集合.

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.

与您的DataForm相同,只需将您的项目绑定到它,它便会为您创建所有适当的字段.

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

这篇关于Silverlight 3 Dataform-如何在运行时添加场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 07:59