来自model属性的WPF Datagrid动态列

时间:2017-03-11 03:46:07

标签: c# wpf mvvm datagrid

将WPF数据网格与MVVM结构一起使用(后面没有代码)。我想知道是否有可能采用通常显示在单个列中的模型属性并使用它来动态生成新列。

实施例

public Class1
{
    public int Property1 { get; set; }
    public string Property2 { get; set; }
    public double Property3 { get; set; }
}

模拟标准数据网格

|Property1|Property2|Property3|
| 1       | A       | 1.25    |
| 2       | B       | 2       |
| 3       | B       | 3       |

模拟所需的datagrid

|Property1| A     | B   |
| 1       | 1.25  |     |
| 2       |       | 2   |
| 3       |       | 3   |

对Property2的价值没有限制。

0 个答案:

没有答案