其中表/网格控制在WPF? [英] Which Table/Grid Control in WPF?

查看:206
本文介绍了其中表/网格控制在WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找显示表格数据(电视频道),但与选项,如DataGrid中/ UniformGrid /表使用的FlowDocument /等。我无法弄清楚什么是最好的选择。主要的问题是,这些细胞不统一的大小,因为它变化的基础上的时间长了,我希望把他们之间的填充为好。此外,我只需要能够显示该台的一部分,并让他们向上/向下滚动/右来查看其余部分。

I am looking to display tabular data (tv channels), but with options such as DataGrid/UniformGrid/Table with FlowDocument/etc. I cannot figure out what would be the best option. The main issues is that the cells aren't uniform in size as it varies based on length of time, and I would like to put padding between them as well. Additionally, I need to only be able to display a portion of the table, and allow them to scroll Up/Down/Right to view the rest.

什么是最好的WPF控件选呢?这里是一个小图什么,我去为的。白方在左上角是什么,我会想显示在启动,并让他们滚动到它的其余部分。

What would be the best WPF Control Option for this? Here is a small illustration of what I am going for. The white square in the upper left is what I would want to display at start, and allow them to scroll to the rest of it.

推荐答案

有几种方法来完成你想在这里做什么。如果性能是不是一个问题,然后我会忽略虚拟化和尝试<一href="http://msdn.microsoft.com/en-us/library/system.windows.controls.dockpanel.aspx"><$c$c>DockPanel这里的缺点是,你将不得不增加,以便该物品而不是由行增加他们。

There are several ways to accomplish what you're trying to do here. If performance is not an issue then I would ignore virtualization and try the DockPanel The drawback here is that you would have to add the items in order rather than adding them by row.

另一种选择是使用两个堆叠板(在每个方向上一个)。这解决了上述问题增加,但是需要使用更多的电池板。

Another option would be to use two stack panels (one in each direction). This addresses the adding issue, but requires the use of more panels.

两者的previous两种方案都需要不同的物品,让他们的高度/宽度集。

Both of the previous two options would require individual items to have their height/width set.

这是最后的选择(取决于你有多大的电网),将使用固定大小的行和列的网格,跨行项目(使用的rowspan 的属性)。这种方法的缺点是,我不知道要创建这个控制的XAML行/列的数目不详什么好的办法,所以你将不得不在code创建它让行/列所需要的数

A final option (depending on how large your grid is), would be to use a Grid with fixed sized rows and columns with items that span rows (using the rowspan property). The drawback of this method is that I don't know of any good way to create this control in xaml for unspecified numbers of rows/columns so you would have to create it in code to get the needed number of rows/columns.

如果您有性能问题,你可以尝试使用<一个href="http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.aspx">VirtualizingStackPanel.如果这还不能满足您的性能需求,那么你将需要继承的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingpanel"><$c$c>VirtualizingPanel和定制以满足您的特定需求。

If you have performance issues you could try using the VirtualizingStackPanel. If this still doesn't meet your performance requirements then you will need to subclass the VirtualizingPanel and tailor it to meet your specific needs.

请参阅<一href="http://stackoverflow.com/questions/9946811/in-what-order-are-panels-the-most-efficient-in-terms-of-render-time-and-performa/9996707#9996707">here关于面板性能的详细信息。

See here for more information on Panel performance.

我建议首先尝试两个的StackPanel 方法,那么 VirtualizingStackPanel 方法,最后,如果不工作,然后尝试 VirtualizingPanel

I suggest trying the two StackPanel method first, then the VirtualizingStackPanel method and finally, if that doesn't work, then try the VirtualizingPanel

填充很容易通过设置保证金财产上的每个子控件来实现的。

Padding is easily accomplished by setting the Margin property on each subcontrol.

有关滚动使用 的ScrollViewer

For scrolling use the ScrollViewer

这篇关于其中表/网格控制在WPF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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