如何在代码中设置DataGridTextColumn的绑定? [英] How can I set the binding of a DataGridTextColumn in code?

查看:67
本文介绍了如何在代码中设置DataGridTextColumn的绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CodePlex的工具包:DataGrid。

I'm using the toolkit:DataGrid from CodePlex.

我正在代码中生成列。

如何在代码中设置 {Binding FirstName} 的等效项?

How can I set the equivalent of {Binding FirstName} in code?

或者,如何设置,这就是我要做的,不一定要绑定它。我只是想从datagrid的单元格中的模型属性获得值。

Or alternatively, how can I just set the value, that's all I need to do, not necessarily bind it. I just want the value from my model property in the cell in the datagrid.

DataGridTextColumn dgtc = new DataGridTextColumn();
dgtc.Header = smartFormField.Label;
dgtc.Binding = BindingBase.Path = "FirstName"; //PSEUDO-CODE
dgtc.CellValue= "Jim"; //PSEUDO-CODE
CodePlexDataGrid.Columns.Add(dgtc);


推荐答案

未经测试,但是以下方法可以工作:

Untested, but the following should work:

dgtc.Binding = new Binding("FirstName");

这篇关于如何在代码中设置DataGridTextColumn的绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆