自定义动态网格

时间:2014-01-16 12:31:10

标签: wpf dynamic grid

我正在尝试在网格中显示项目,但是应该动态生成行和列。我实际上实现了一个源自Grid控件的自定义控件,并提供了其他属性,例如RowCount

这是我的自定义控件使用两个尺寸字符串数组作为数据源生成的网格图片:

enter image description here

但我认为我的控件消耗的资源超过了所需的资源,因为它只会破坏列和行定义并重新创建它们。有没有更简单的方法来实现该控制?

1 个答案:

答案 0 :(得分:1)

您无需为自己创建自定义控件...您可以使用标准DataGrid。关于在DataGrid中显示动态数据存在许多问题。请看一些这些帖子:

How do I bind a WPF DataGrid to a variable number of columns?
DataGridColumn Binding with Dynamically Generated Data
Visualizing 2D Data in a Table
Displaying multidimensional data in WPF

相关问题