简体   繁体   English

WPF Datagrid ItemsSource

[英]WPF Datagrid ItemsSource

I have a dynamic set of columns and when I populate the rows and know only the columnname of the rows. 我有一组动态的列,当我填充行并且只知道行的列名时。 Is that possible to do? 那有可能吗?

A list of columns: 列列表:
Columns[0] = "firstcol"; 列[0] =“ firstcol”;
Columns[12] = "anothercol"; Columns [12] =“ anothercol”;

And a list of rows. 和行列表。
First row 第一排
Rows[0][0] = "item"; Rows [0] [0] =“ item”;
Rows[0][12] = "item"; Rows [0] [12] =“ item”;

Second row 第二排
Rows[1][0] = "item"; Rows [1] [0] =“ item”;
Rows[1][12] = "item"; Rows [1] [12] =“ item”;

I need to populate the datagrid. 我需要填充数据网格。 Can that be done, with a dictionary or something, as I do not know the columns... 可以用字典之类的东西来完成,因为我不知道这些列...

If you can manage to create a structure, - Row - Column Header - Cell Data 如果可以管理创建结构,则-行-列标题-单元格数据

Also expose the List of column to your control (maybe bind it) then on update of it dynamically create columns and attach cell template, cell edit template (data templates, where you specify the binding with the source item and paths). 还向控件公开列列表(可能绑定它),然后在其更新时动态创建列并附加单元格模板,单元格编辑模板(数据模板,在其中指定源项和路径的绑定)。 This way your dynamic columns will be added and binding will be established thus any changes in the rows or the data will be updated between your 'presenter' and 'view' (wpf datagrid control) 这样,将添加动态列并建立绑定,因此行中的任何更改或数据将在“ presenter”和“ view”之间更新(wpf datagrid控件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM