c# - 如何在代码中设置 DataGridTextColumn 的绑定(bind)?

标签 c# wpf datagrid

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

我正在用代码生成列。

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

或者,我怎样才能设置值,这就是我需要做的,不一定要绑定(bind)它。我只想要数据网格中单元格中模型属性的值。

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

最佳答案

未经测试,但以下应该有效:

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

关于c# - 如何在代码中设置 DataGridTextColumn 的绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/916454/

相关文章:

wpf - WPF Datagrid -DataGridTemplateColumn选项卡焦点问题

WPF TreeView 动态分组

wpf - Windows 7 触摸屏 "Shrug"

c# - 为什么 dataTable.Rows[0] ["columnName"] == null。不工作?

c# - 实现接口(interface)的 Blazor 组件列表

wpf - 如何改变wpf TabControl中TabItem的顺序

c# - DataGrid 中的数据重复。 LINQ 查询的问题

c# - DataGrid 自动生成的列 : Increasing width

c# - ReBus 相当于 NServiceBus Saga ReplyToOriginator

c# - C# 中的简单多线程程序无法正常工作