WPF DataGrid中的动态行和列跨度 [英] Dynamic row and column span in WPF DataGrid

查看:244
本文介绍了WPF DataGrid中的动态行和列跨度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个新项目,该设计要求以某种网格形式显示动态行和列。我想我可以使用普通的ol'Grid非常巧妙地完成此操作,但似乎应该可以使用真实网格。

I'm working on a new project where the design calls for dynamic rows and columns displayed in some form of grid. I think I can accomplish this very hackishly using the plain ol' Grid, but it seems like it should be possible using a "real" grid.

在我的模型中,我用红色圈出了一些棘手的地方。在第1列下,我实际上有2列数据。问题是我的第1列中的数据可以跨越多行。第一列实际上是两个伪列,每个列可以独立地跨越不同数量的行。注意:数据是伪造的,无关紧要的。我愿意提出一个好的实施方案。我可以退回到Grid并在后面的代码中完成所有操作,我愿意购买一个可能比DataGrid强大的数据网格,而我的 last 绝对选择/偏好是重构这种格式

In my mockup, I circled the tricky bit in red. Under column 1, I have effectively 2 columns of data. The problem is the fact that my data in column 1 can span multiple rows. And the fact that column one is really two pseudo columns and each one can span a different number of rows independently. Note: the data is fake and inconsequential. I'm open to ideas for a good implementation. I can fall back to the Grid and do this all in code behind, I'm open to purchasing a datagrid that may have more power than the DataGrid and my absolute last resort/preference is to restructure this format to something a little more doable.

感谢您提供的任何想法。

Thank you for any ideas you can provide.

推荐答案

大多数商业WPF DataGrid实现都像这样处理分层数据。例如, Telerik的DataGrid (用于WPF的RadControls的一部分)支持分层数据

Most commercial WPF DataGrid implementations handle hierarchical data like this. For example, Telerik's DataGrid (part of RadControls for WPF) supports hierarchical data in multiple formats.

通常,默认样式与上面的样式有所不同,但是可以通过样式适应该格式。

Typically, the default styling is a bit different than yours above, but can be adapted to that format via styling.

这篇关于WPF DataGrid中的动态行和列跨度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆