Bind Objects with generic list to wpf datagrid

天大地大妈咪最大 提交于 2019-12-25 04:58:05

问题


I like to display my data objects:

class DataElement
{
    public string name { get; set; }
    public List<customProperty> properties { get; set; }
}

class customProperty
{
    public String value;
    public String definition;
}

in a datagrid like:

Name                    | dataElementList[0].properties[0].definiton | dataElementList[0].properties[1].definiton | dataElementList[0].properties[2].definiton | ...
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
dataElementList[0].Name | dataElementList[0].properties[0].value     | dataElementList[0].properties[1].value     | dataElementList[0].properties[2].value     | ...
dataElementList[1].Name | dataElementList[1].properties[0].value     | dataElementList[1].properties[1].value     | dataElementList[1].properties[2].value     | ...
....

The property definition are the same for all elements. How can i bind my data structures to a datagrid with CellTemplates?

来源:https://stackoverflow.com/questions/39719910/bind-objects-with-generic-list-to-wpf-datagrid

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