在WPF工具包的DataGrid中跨多行记录 [英] Spanning a Record Over Multiple Rows in WPF Toolkit's DataGrid

查看:70
本文介绍了在WPF工具包的DataGrid中跨多行记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为WPF Toolkit的DataGrid设置样式,以便数据记录可以跨越多行。 屏幕截图示例来自商业控制。

Is it possible to style WPF Toolkit's DataGrid so a data record can span multiple rows. Example screen shot from a commercial control.

谢谢,

Ben

Thanks,
Ben

推荐答案

使用工具包DataGrid或GridView无法实现ListView,不是。

It is not possible with the toolkit DataGrid or GridView for a ListView, no.

但是我最近发现您可以使用 GridViewHeaderRowPresenter MSDN参考),将 Columns 属性设置为所需的列:给您一个标题行。

However you may have luck with your own implementation, as I recently discovered you can use GridViewHeaderRowPresenter (MSDN reference), set the Columns property to the columns you want: that will give you a header row.

然后您可以使用 GridViewRowPresenter MSDN参考),将其附加到同一 Columns 集合,瞧,行和标题中的列将被链接(调整标题大小,更改列)。

Then you can use GridViewRowPresenter (MSDN reference), attach it to the same Columns collection and voila, your columns in the rows and header will be linked (resize the header, the columns change).

请参见此处的示例:


http://msdn.microsoft.com/zh-CN/library/ms752313.aspx

为了获得叠加效果,您可以创建 ListView ListBox ,对于每个项目,您将输出一对垂直堆叠的 GridViewRowPresenter 控件,每个控件都绑定到一个单独的列集合。然后,在您自己的自定义标头(位于控件上方)中,将使用一对 GridViewHeaderRowPresenter 控件执行相同的操作。

In order to get the stacked effect, you could create a ListView or ListBox, and for each item you'd output a vertically-stacked pair of GridViewRowPresenter controls, each bound to a separate columns collection. Then in your own custom header (just above the control) you'd do the same thing with a pair of GridViewHeaderRowPresenter controls.

然后,您也可以添加其他任意位,例如它们在示例屏幕快照中具有的文本/标签。

You could then add any other bits you'd like as well, for example the text/label that they have in your example screenshot.

没有理由这不应该工作。它不是预先构建的解决方案,但可以通过干净的编码实现,它不是hack,您可以完全控制其外观和工作方式!添加排序等也很容易,MSDN也提供了一个示例。

No reason why this shouldn't work. It's not a pre-built solution but is possible with clean coding, it's not a hack, and you have complete control over how it looks and works! Adding sorting and so on is fairly easy too, MSDN has an example for that too.

希望有帮助-有关此细节的更多疑问,请在此处添加评论!

Hope that helps - any more questions on the details of this please add a comment here!

这篇关于在WPF工具包的DataGrid中跨多行记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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